Question

You are working on a program where you are going to be storing data in a...

You are working on a program where you are going to be storing data in a sorted list, and every time you added a piece of data, you would need to put it into the correct location in the sorted list. Which of the two data structures is best for this and why?

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

First,
We can use Linked Lists because it allows to insert without reallocation of the entire structure.
The data items are need not to store on memory or disk contiguously and linked list are good for large data but it does not provide random access to its nodes.
Since we insert a data to sorted linked list, therefore, its time complexity will be O(n) where n is number of data pieces.
{ For searching its right place = O(n) + For inserting new node = O(1) }

Second,
We can use Array with Insertion Sort as it also works in linear time i.e. O(n).

I don't suggest Heap Data Structure although it works in O(log n) beacause it is patially ordered not completely sorted.

Add a comment
Know the answer?
Add Answer to:
You are working on a program where you are going to be storing data in 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
  • C++ Program 1. Read data for names and weights for 15 people. 2. Your program will...

    C++ Program 1. Read data for names and weights for 15 people. 2. Your program will build a list for the data maintained in ascending order based on both name and weight via a doubly linked list. 3. This dll will use one pointer to keep weights in sorted order, and use the other link to keep names on sorted order. 4. You need to build the list as you go maintaining this ordering, so at any time a print...

  • C++ Program 1. Read data for names and weights for 15 people. 2. Your program will...

    C++ Program 1. Read data for names and weights for 15 people. 2. Your program will build a list for the data maintained in ascending order based on both name and weight via a doubly linked list. 3. This dll will use one pointer to keep weights in sorted order, and use the other link to keep names on sorted order. 4. You need to build the list as you go maintaining this ordering, so at any time a print...

  • Suppose you are implementing the address book feature for a cellphone. The address book needs to be kept sorted by pers...

    Suppose you are implementing the address book feature for a cellphone. The address book needs to be kept sorted by person’s last name and support fast access when queried by last name. Which of the following data structures would be a good choice to use for storing the address book? Explain why. Which would be the bad choice and why? a. unsorted linked list (b) sorted linked list b. binary search tree (d) hash table

  • 1. Suppose you are implementing the address book feature for a cellphone. The address book needs to be kept sorted by pe...

    1. Suppose you are implementing the address book feature for a cellphone. The address book needs to be kept sorted by person’s last name and support fast access when queried by last name. Which of the following data structures would be a good choice to use for storing the address book? Explain why. Which would be the bad choice and why? a. unsorted linked list (b) sorted linked list b. binary search tree (d) hash table. 2. Write an algorithm...

  • Storing data and adding to data in a dictionary: Experiment with Python dictionaries and their keys()...

    Storing data and adding to data in a dictionary: Experiment with Python dictionaries and their keys() member function that returns a list of a dictionary's keys. You can check if a particular key is in a dictionary by using the in test with the keys list. For example, if our dictionary is MyDict = { 1: 'One', 2: 'Two', 3: 'Three' } Then ( 2 in MyDict.keys() ) evaluates to True, indicating that 2 is a valid key for MyDict....

  • In this assignment, you are going to write a program that will calculate x*x by using shift opera...

    Please solved IAR workbench in C language I have a limited time less than 10 hours In this assignment, you are going to write a program that will calculate x*x by using shift operations. Details are as follows: x can be any number between 1 - 100. The result x*x will be stored in 0x20000000. You may first find the binary representation of x. In the binary representation, if you see a 1 in the nth bit, you will shift...

  • For this program, you will be working with data from the NASA website which lists Near...

    For this program, you will be working with data from the NASA website which lists Near Earth Objects detected by the JPL Sentry System. You are given a text file listing the designation and impact probability (with Earth, generally within the next 100 years) of 585 Near Earth Objects. Your job will be to sort these objects by their impact probabilities. Input File Format The input file contains 585 records. Each record is on a separate line. Each line contains...

  • Please write comments so the user will understand the program. The output for the calculation is provided below thw assignment. For this assignment, you will take on the role of a member of an...

    Please write comments so the user will understand the program. The output for the calculation is provided below thw assignment. For this assignment, you will take on the role of a member of an IT department. Your chief technology officer (CTO) has tasked your department with the replacement of IT equipment. Your manager does not want to buy a piece of equipment based on the brand name alone. Rather, your manager wants to know the return on investment for each...

  • you are going to write a program, fastfactor, to find all the inegral factors of a...

    you are going to write a program, fastfactor, to find all the inegral factors of a number (integer). the program must be written in C. note that in C (as in most languages) % is a remainder operator, so if x % 3 == 0 that means 3 is a factor of x. you are going to write fastfactor to work like a "standard" UNIX command: the user can invoke the command like fastfactor 12 13 which would output 12:...

  • Create a Java program that analyzes a program and produces the output into another file. The...

    Create a Java program that analyzes a program and produces the output into another file. The program must retrieve the path to the .java file. Once the path to the file is found the program must figure out the length of the longest line is in the program. For example, working with a program called MainFile.java. Once it figures out the longest line in the code it will put the output into MainFile.java.stats and it will be located in the...

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