Question

Can Anyone help me to answer these question regarding Algorithm in the computer science? 1) a)...

Can Anyone help me to answer these question regarding Algorithm in the computer science?

1) a) Describe the merge helper method of Merge Sort.

     b) What are real life examples of Bubble Sort, Selection Sort, and Insertion Sort?

    c) What does it mean for a tree to be complete?

    d) Describe the partition helper method of Quicksort.

    e) What are two real life examples of a Priority Queue?

   f) Draw a min heap with at least 8 nodes.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a)

The merge helper method of the Merge sort algorithm is used to merge two sorted arrays into a single sorted array.

b)

Consider you have 8 shoes pairs with sizes 6 to 13. You find them not in order. Their arrangement from smallest to largest will be an example of selection sort.

Lined up in a random order in front of the teacher, who’s put to the task of lining you all up in an ascending order of height. The bubble sort algorithm comes in handy here.

When we are playing cards each time we take new card and insert at its proper position that's an example of insertion sort.

c)

A Binary Tree is complete Binary Tree if all levels are completely filled except possibly the last level and the last level has all keys as left as possible

d)

partition (arr[], low, high)
{
    // pivot (Element to be placed at right position)
    pivot = arr[high];  
 
    i = (low - 1)  // Index of smaller element

    for (j = low; j <= high- 1; j++)
    {
        // If current element is smaller than the pivot
        if (arr[j] < pivot)
        {
            i++;    // increment index of smaller element
            swap arr[i] and arr[j]
        }
    }
    swap arr[i + 1] and arr[high])
    return (i + 1)
}

NOTE: As per Chegg policy, I am allowed to answer specific number of questions (including sub-parts) on a single post. Kindly post the remaining questions separately and I will try to answer them. Sorry for the inconvenience caused.

Add a comment
Know the answer?
Add Answer to:
Can Anyone help me to answer these question regarding Algorithm in the computer science? 1) a)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Which is the best sorting algorithm for larger arrays if all the items can not...

    1. Which is the best sorting algorithm for larger arrays if all the items can not fit in main memory? selection sort insertion sort quicksort Merge sort 2. Which sorting algorithm sorts items without comparing them? quick sort radix sort merge sort Insertion sort 3 What is the average running time for quicksort? O(n2) O(logn) O(nlogn) O(n) O(n2logn) 4. Examine the steps of the following algorithm and write the name of the algorithm described in the blank provided: Recursively divide...

  • For java review please help #2 2. (15 points (-14+1)) Compare the execution complexity of sorting...

    For java review please help #2 2. (15 points (-14+1)) Compare the execution complexity of sorting algorithms. Worst Case Average Case Selection Sort (2.1) Bubble Sort (2.2) Insertion Sort (2.3) Radix Sort Merge Sort Quicksort Heap Sort (2.8) (2.9) (2.10) (2.4) (2.5) (2.6) (2.7) (2.12) (2.13) (2.14) 3. (10 points) Answer the following questions for an array based representation of a complete binary tree (say the array name is binTree). (3.1) root of tree bin Tree LoT

  • Puodace a char showing the number of moves required to solve the Towers of Hanoi puzle using t 30...

    Puodace a char showing the number of moves required to solve the Towers of Hanoi puzle using t 30. What is an execution frame? What is an activation record? What is contained in it? 31. Write a recursive Java method that computes the factorial of a number 2. Linear search may require up to comparisons while binary search will only require roughly comparisons 33. Sort sorts a list of values by repetitively putting a particular value into its final, sorted,...

  • Computer Algorithm question 8) Give an algorithm for building a heap in O(n) 9) Prove the...

    Computer Algorithm question 8) Give an algorithm for building a heap in O(n) 9) Prove the algorithm given in 8) runs in O(n) time. 10) What is the asymptotic runtime of an algorithm represented by the following recurrence equation? 11) Suppose you have the following priority queue implemented as a (max) heap. What will the heap look like when the max node is removed and the heap is readjusted? Assume on each heapify operation the largest child node is selected...

  • Modify the sorts (selection sort, insertion sort, bubble sort, quick sort, and merge sort) by adding code to each to tally the total number of comparisons and total execution time of each algorithm. E...

    Modify the sorts (selection sort, insertion sort, bubble sort, quick sort, and merge sort) by adding code to each to tally the total number of comparisons and total execution time of each algorithm. Execute the sort algorithms against the same list, recording information for the total number of comparisons and total execution time for each algorithm. Try several different lists, including at least one that is already in sorted order. ---------------------------------------------------------------------------------------------------------------- /** * Sorting demonstrates sorting and searching on an...

  • Can you give me a poste for Science Writing TOPIC: DECISION TREE Decision Tree Algorithm Pseudocode:-...

    Can you give me a poste for Science Writing TOPIC: DECISION TREE Decision Tree Algorithm Pseudocode:- 1) Place the best attribute of the dataset at the root node of the tree. 2) Split the training set into subsets. Subsets should be make in such a way that each subset contains data with the same value for an attribute. 3) Repeat steps 1 and 2 on each subset until you find leaf nodes in all the branches of the tree. Two...

  • Can I get some help with this question for c++ if you can add some comments...

    Can I get some help with this question for c++ if you can add some comments too to help understand that will be much appreciated. Code: #include <cstdlib> #include <getopt.h> #include <iostream> #include <string> using namespace std; static long comparisons = 0; static long swaps = 0; void swap(int *a, int *b) {     // add code here } void selectionSort(int *first, int *last) {     // add code here } void insertionSort(int *first, int *last) {     // add code here }...

  • problem 2 can use Det-Selection(A, p, q, r) as a sub-routine (i.e, you don't need to...

    problem 2 can use Det-Selection(A, p, q, r) as a sub-routine (i.e, you don't need to write its pseudo-code). To sort an array A, you will then call Det-QuickSort(A, 1, n). You also need to provide the worst case time complexity analysis of your algorithm. 2. (20 points) Given a set of n distinct numbers, we wish to find the k largest in sorted order using a comparison-based algorithm. Give an algorithm that implements each of the following methods, and...

  • For each of the following, give the correct answer by circling one of the two choices....

    For each of the following, give the correct answer by circling one of the two choices. TRUE or FALSE. The average-ease running time of an algorithm, over all inputs of size n, is always more than its worst-ease running time. TRUE FALSE log_b(a * c) = log_b a* log_b c. TRUE FALSE Stacks support insertions and deletions in the first-in first-out (FIFO) principle.TRUE FALSE An array of size n can support insertAtRank operation in worst-ease O(1) time.TRUE FALSE A heap...

  • Short answer in your own word: 1. Describe the role of a “Back-End” computer engineer in...

    Short answer in your own word: 1. Describe the role of a “Back-End” computer engineer in creating software. Give examples of decisions back end engineers make. Use the relationship between long-term and short-term memory as context for decision examples. 2. Identify Stack or Heap storage in RAM. a) Hash Map with static array as underlying storage b) Doubly Linked LIst - Stack Implementation c) Binary Search Tree with 10,000 Nodes d) Static Array - Stack Implementation c) Doubly Linked List...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT