Write a sortedinsert function in c program

Assignment Help Data Structure & Algorithms
Reference no: EM131175030

Assignment

Q1. Write a complete C++ program to create a table as shown below. User inputs the width of the table, after creating the shape your program should calculate the sum of the elements in a particular row entered by the user.

Example run:
Width of the shape? (Enter odd number only) 9
Enter row number to get sum 5
Answer:

1576_Shape.jpg

Sum of row 5 is 45

Q2. Write the following functions and then a complete C program, assuming the node type used is as follows:

struct node {
int data;
struct node* next;
};

and head is the head pointer of a list:

struct node* head;

a) Write a sortedInsert() function in C program that takes two parameters:

i. a list that is sorted in increasing order, and
ii. a single node,

which inserts the node into the correct sorted position in the list. You should use the following function header:

voidSortedInsert(struct node** headRef, struct node* newNode) {

// Your code...

b) Write another function named removeRedundant() which takes a list sorted in increasing order and deletes any duplicate nodes from the list. Ideally, the list should only be traversed once.

/* Remove duplicates from a sorted list. */

voidRemoveDuplicates(struct node* head) {

// Your code...

Q3. Create a linked list using C, print the linked list and then call a function to delete a specified node. In your delete function

i. check if the first node matches with the ‘key' value, if it matches delete the first node.
ii. if the key value doesn't match with the first node then call a find_node () function to find the location of the particular node that containing the item to be deleted.

Print your linked list after the deletion process.

551_Linked List.jpg

Q4. Write a complete C program, that Uses a one-dimension array to read 20 numbers, each of them is between 0 and 100, inclusive.

a. Uses a bubbleSort() function to sort the array in ascending order. Discuss the Big O of your sorting algorithm for the best case and worst case scenarios.

b. Write another function that improve the performance of your program by using another sorting algorithm (any algorithm learned in the lecture), discuss the Big O of the new algorithm used.

Reference no: EM131175030

Questions Cloud

Which aspect of the assignment was most challenging : Discuss your experience when applying new learning or existing knowledge to a real-world software application. Which aspect of the assignment was most challenging? How did you resolve this issue? Describe your experience.
Prepare general journal entries for bronson ltd : Prepare general journal entries for Bronson Ltd for Machines A and B during the period from 1 January 2015 to 30 June 2015.
Newspaper cut advertising rates substantially : Samuelson and Marks, Questions and Problems 1, p. 261.In 2002, the Atlanta Journal and the Atlanta Constitution, once fierce competitors, merged to become the Atlanta Journal-Constitution, the only remaining daily newspaper in the city.
How each theory would conceptualize henry problem : How each theory would conceptualize Henry's problem, including how they would differ. What each theory would suggest needs to be changed for Henry.
Write a sortedinsert function in c program : Write a sortedInsert() function in C program that takes two parameters: a list that is sorted in increasing order, and a single node,
Law of downward-sloping demand : College enrollments increased at the same time that average tuition rose dramatically. Does this contradict the law of downward-sloping demand? Explain briefly.
Is character an essential ingredient in ethical leadership : Do you agree with the Waiter Rule? Does it provide useful insights into who might be an ethical or unethical leader? Should corporate boards consider character when hiring someone for the top position?
What laws govern employment relations in china : Assess the strengths and the weaknesses of the role that the state plays in the system of employment relations in China. ISSUES TO BE ADDRESSED- Why is this question being asked? What laws govern employment relations in China
Calculate the required ratio of volume flow rate in shell : Calculate the required ratio of the volume flow rate in the shell to that in the tube if the average velocity of flow is to be the same in each.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Question about branch hazard

Provide a relevant example using MIPS instruction set architecture. Discuss the similarities and differences of the code will proceed it the branch is taken, vs if the branch is not taken, and explain how this affects the pipeline.

  Database design

As with the previous exams(SQL,E-R diagram and Normalization, you may complete this assignment at any time up to its due date of December 8, 2013.

  Implement the decision tree about car problem

Implement the decision tree about car problem found in the Lesson USING CLIPS TO MAKE A RULE BASED SYSTEM at the end of this module. Submit source code and 5 test cases in the drop box provided.

  Supposing that the set of possible list values abcd sort

assuming that the set of possible list values abcd sort the following list in alphabetical order by the distribution

  Write algorithm to prompt for and accept four numbers

Write the algorithm which will prompt for and accept four numbers, sort them into ascending sequence and display them to screen. Your algorithm is to include module called Order _two_numbers.

  Write a class called reverse to reverse an unsigned integer

Write a class called reverse to reverse an unsigned integer. For example, 8602 should be written as 2068 • Write the program above, using only while statements • Rewrite the program using only for statements

  Write an algorithm that converts linear measurement in feet

Write an algorithm that converts a linear measurement in feet and inches into meters. One inch is equivalent to 2.54 centimeters.

  Documentation and proper design procedures

Determine the main reason that make many developers skip over the documentation and proper design process? As a manager, discuss how do you ensure that the proper database design process are followed by database development teams?

  Implement the quick select algorithm

Implement the Quick-Select Algorithm. To choose a pivot point, Pivot = median Then move pivot to the last element. Ideal number to sort. 8,1,4,9,6,3,5,2,7,0

  Build a dynamic and functional model

Write 2 to 3 page paper that explains the difference in steps used to build a dynamic and functional model as each relates to object-oriented modeling

  How does the algorithm you chose affect the result

How do the algorithm techniques of fragmentation affect the end result of sorting through larger amounts?

  Write steps involved in performing binary search operation

Write the steps involved in performing binary search operation to search an element 56 in the following numbers.

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