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

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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