Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
1. Using the following code c++ please insert a merge sort
2.compare the first code with a counter sort to see wish one is faster.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 4 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.Similar questions
- Answer in c++arrow_forwardcreate a function in python parameters: 1. dict[str, list[str]] 2. list[str] return type: dict[str, list[str]] must do like this: 1. establish an empty dictionary that will serve as the dictionary returned at the end 2. loop thorugh each of the columns in the second parameter of the function 2a. asssign to the column key of the result dictionary the list of values stored in the input dictionary at the same column 3. return the dictionary produced do not import other libraries such as pandas, .select, .head, .iloc or anything this function is being used to work in a dataframearrow_forwardd. Apply the Binary Search Algorithm, as performed during class, show all the necessary steps. Use the Algorithm presented during class. Search for the key 10.. List = [2, 4, 7, 10, 11, 34, 50, 59, 60, 66, 69, 70,7 9]arrow_forward
- Q1. Apply Merge Sort and Quick Sort to the list, C , 0 , M , P, U,T,E,R in alphabetical order.arrow_forwardWhich sort usually requires fewer data values to be swapped, bubble sort or selection sort?arrow_forwardModify the recursive Fibonacci function to employ the memoization technique discussed in this chapter. The function creates a dictionary and then defines a nested recursive helper function named memoizedFib. You will need to create a dictionary to cache the sum of the fib function. The base case of the fib function is the same as before. However, before making any recursive calls, the helper function looks up the value for the function’s current argument in the dictionary (use the method get, with None as the default value). If the value exists, the function returns it and skips any recursive calls. Otherwise, after the helper function adds the results of its two recursive calls, it saves the sum in the dictionary with the current argument of the function as the key. Note: The program should output in the following format: n fib(n) 2 1 4 3 8 21 16 987 32 2178309 ---------------------------------------------------------------------------------- def…arrow_forward
- Output the execution time for the quick sort, selection sort, insertion sort, bubble sort, and merge sort algorithms as they attempt to sort an array of 1000 random numbers, 1000 sorted number, and 1000 numbers in reversed order. For this use the the high_resolution_clock::now() function that will return the current time. To use this you will also need to include the header file as well as using namespace std::chrono. Quick sort 187 ms for random numbers 176 ms for sorted numbers 173 ms for reversed numbers Selection sort 1300 ms for random numbers 1424 ms for sorted numbers 2578 ms for reversed numbers Insertion sort 401 ms for random numbers 1 ms for sorted numbers 1 ms for reversed numbers Bubble sort 1366 ms for random numbers 669 ms for sorted numbers 667 ms for reversed numbers Merge sort 1297 ms for random numbers 1049 ms for sorted numbers 1010 ms for reversed numbersarrow_forwardLanguage: C++ Write a Program with Comments for your code to improve quick sort. The quick sort algorithm presented in the ClassNotes-Sorting selects the first element in the list as the pivot. Revise it by selecting the median among the first, middle, and last elements in the list. Code to be revised: #include <iostream>using namespace std; // Function prototypesvoid quickSort(int list[], int arraySize);void quickSort(int list[], int first, int last);int partition(int list[], int first, int last); void quickSort(int list[], int arraySize){quickSort(list, 0, arraySize - 1);} void quickSort(int list[], int first, int last){if (last > first){int pivotIndex = partition(list, first, last);quickSort(list, first, pivotIndex - 1);quickSort(list, pivotIndex + 1, last);}} // Partition the array list[first..last]int partition(int list[], int first, int last){int pivot = list[first]; // Choose the first element as the pivotint low = first + 1; // Index for forward searchint high = last;…arrow_forwardDefine a sort function as below void sort(struct Employee * base], int n, int (*compareFunc)(struct Employee ** struct Employee **)) { qsort((void **)base,n,sizeof(void *),(int (*)(const void *,const void *))compareFunc); } Q1) What does the line in the provided sort function do? Describe each of the 4 arguments being passed to qsort. What do we need that big strange cast for the fourth argument?arrow_forward
- Do this using C++ language using structures and singly linked list.arrow_forwardLanguage: C++ Write a Program with Comments for your code to improve quick sort. The quick sort algorithm presented in the ClassNotes-Sorting, it selects the first element in the list as the pivot. Revise it by selecting the median among the first, middle, and last elements in the list.Explain your Outputs or Answers for the following: (C) Give a list of n items (for example, an array of 10 integers) representing the worst-case scenario. (D) Give a list of n items (for example, an array of 10 integers) representing the best-case scenario. Please compile your answers in a file including all source code with comments, Explain your running Outputs or Answers in (A) ~(D). Quicksort that was mentioned in the ClassNotes: #include <iostream>using namespace std; // Function prototypesvoid quickSort(int list[], int arraySize);void quickSort(int list[], int first, int last);int partition(int list[], int first, int last); void quickSort(int list[], int arraySize){quickSort(list, 0,…arrow_forwardC++arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY