Write a function to make a new list

Assignment Help C/C++ Programming
Reference no: EM131681857

Project -

In your project you will implement singly linked lists in C. You will test your program by creating an ordered linked list of integers. You will then use your implementation to write a program that creates a representation of a deck of cards and makes a random shuffle of the deck. The algorithms for implementing linked lists will be discussed in your classes.

Therefore, this description does not list implementation details of the required functions.

Detailed requirements for linked lists implementation:

You will need to write several functions.

0. To represent a node in a linked list you can use a structure

typedef struct Node f

SomeDataType data;

struct Node *next;

} ListNode;

where SomeDataType can be any C data type.

1. Write a function to make a new list. Your function should create a dummy head node to represent an empty list.

ListNode *newList(void) // returns a head of a new empty list

2. Write functions to insert elements into a list and to remove elements from a list ListNode *removeNode(ListNode * prev); // removes the node after prev

ListNode *insertNode(ListNode *prev, SomeDataType data)

// inserts a new node with data field data after prev

3. Write functions to count the number of elements in a list without the head and to print the list

int length(ListNode *head) // number of elements in the list

void printList(ListNode *head) // print the data fields for the entire list

Note that printList will print the linked list implemented to support the second part of your project.

To test your code you will use it to make an ordered list of random integers. After that you will write functions to manipulate a deck of cards. You should assume that a full deck contains 52 cards: card values (A,2,3,4,5,6,7,8,9,10,J,Q,K) in four suits (Spades,Diamonds,Hearts,Clubs).

You can use either integers or enums to represent cards and suits, but you should print card values using their symbols ('A','2',. . . ,'10','J','Q','K') and the suits using first letter of their name. Examples: (10,S),(A,C),(7,D) to stand for 10 of spades, ace of clubs, and 7 of diamonds.

Detailed instructions for ordered list of integers implementation:

To test your linked list code you should generate 10 random numbers in the range [0..1000] and insert them in a ascending order into an empty list. Every time you generate a number you need to traverse the linked list and find a proper place for the number to be inserted. This means that you should not sort numbers before insertion. You should calculate the list length and print it together with the list after each number insertion. Note that for this part to work your data field should be of type int.

Attachment:- Assignment Files.rar

Reference no: EM131681857

Questions Cloud

What is strategic consulting : What is Strategic consulting? What are the best practices for consulting?
Discuss information systems contributed to the healthcare : How have healthcare technologies and information systems contributed to the healthcare in the United States
How would the criminal justice system be different : How would the criminal justice system be different today if the founding fathers had decided not to create a separate system of federal courts.
Consumer behavior-blamed for promoting materialistic society : Advertisers are often blamed for promoting a materialistic society by making their products as desirable as possible.
Write a function to make a new list : CS 262 Project. Write a function to make a new list. Your function should create a dummy head node to represent an empty list
Discuss systems and processes related to new technologies : What are some ways to get physicians to utilize new systems/processes related to new technologies
Identify three of the most successful companies : Identify three of the most successful companies or organizations today, in your opinion.
How would you reduce the federal court caseload : How would you reduce the federal court caseload? In considering where you would reduce federal court jurisdiction, also consider where you might increase it.
What is your solution to the mind-body problem : The crucial question in Dualism is how does the non-material Mind interact with the Material Body. What is your solution to the Mind-Body Problem?

Reviews

len1681857

10/16/2017 4:38:02 AM

Topic: Project 2 in C language. Detailed Question: Teacher's comment: You should always call srandom() in a program (lab, project, video poker machine) that uses random()! Now whether you seed it with a specific value (preferred for labs and projects) or using time(), Your makefile should contain a way to compile both executables with only the "make" or "make all" command. runs it using valgrind. valgrind shows no issues with memory management. The code is commented and indented appropriately, and contains no questionable coding practices. You may NOT use realloc

len1681857

10/16/2017 4:37:56 AM

The teacher doesn't want to use more tools without their teaching, so plz use #include stdio.h #include stdlib.h look at the linklist example to know teacher's style and algorithms for implementing linked lists. They will post the grading details at the last week. If we do well, we will match with the details. If not, could you please fix to get the best grade?

len1681857

10/16/2017 4:37:09 AM

Use script do show your session in which you compile and run your code for various values of n. You should show testing of your functions. You should show the results for both the ordered list of integers and the deck of cards manipulation. Use tar or zip command to create an archive of your script file, your fully commented source code, and your Makefile. All filenames should use the standard naming conventions that were used in the labs. Submit your tar or zip file on Blackboard.

Write a Review

C/C++ Programming Questions & Answers

  Define a class for a type called fraction

Define a class for a type called Fraction. This class is used to represent a ratio of two integers. Include mutator functions that allow the user to set the numerator and the denominator.

  Types of intruder detection techniques

Identify and fully explain two types of intruder detection techniques. With the aid of a fully labeled diagram, explain the use of Public-Key Encryption between two communication devices/users.

  Write a program that will read from a file a series of lines

Write a program that will read from a file a series of lines that contain an individuals first and last name followed by a colon, then three integers.

  Application to accept the name of a folder

Therefore, she asks Hayley to modify the application to accept the name of a folder and display the following details of the files located in the folder: File name File size File creation date. Write the code that Hayley should write to create the..

  Write a c program that allows the user to make transactions

Write a C program that allows the user to make some banking transactions. The program should first prompt the user to enter the current balance of his/her bank account (in dollars and cents).

  Write a test program that prompts the user to enter an index

Rewrite the fib method in Listing 18.2 using iterations. Hint: To compute fib(n) without recursion, you need to obtain fib(n - 2) and fib(n - 1) first. Let f0 and f1 denote the two previous Fibonacci numbers. The current Fibonacci number would the..

  Write a function that sets the value of an integer

Write a function set(int* a, int val) that sets the value of an integer a declared in the calling function, to the value val.

  The conversion of binary numbers to decimal numbers

You will need to use a for() loop to process the eight bits. You will need to use a while() loop to access the numbers in the data file (checking for the end of file). This program will help you read data from a data file, valid the data and proce..

  Using an abstract class with only pure virtual functions

Using an abstract class with only pure virtual functions, create three small classes unrelated by inheritance---clases Building, Car and Bicycle. Give each class some uique appropriate attributes and behaviors that it does not have in common with oth..

  Write code to test the additions to your class

Add a copy constructor to the Huge Number class described in the previous problem that makes a deep copy of the input Huge Number.

  Test a program that prompts for the user

Write and test a program that prompts for the user to input a file name and uses two functions head() and tail() - head() displays the first 10 lines of a file

  Rational class performs operations on fractions

Write a C++ program that, using the rational class performs operations on fractions. Test your class thoroughly.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd