Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CS301 Data Structures GDB Solution Spring June 2012
#1
Suppose you are given a task to develop an electronic phone book in which you have to store names and phone numbers of employees of a company. The data structures available to you are linked list and Binary Search Tree (BST) and you have to choose only one data structure. Moreover, while selecting any data structure, you also have to keep in consideration insertion, deletion and search operations, because, the company can hire some new employees, search for an employee’s phone number and some old employees can also leave this company. Discuss which data structure do you think would be more suitable for the above discussed scenario. Also discuss the reason why would you prefer this data structure over the other?

Solution:

A binary search tree will provide logarithmic searching which is pretty good. Insertions or deletions will be more costly because they may require some tree rebalancing.

For your linked list, are you still going to keep the data in order or just stuff the nodes one after another? If you are putting them in no order, retrieval will be slow (linear) and insertions and deletions still won’t be that fast. The problem with a linked list, if I remember correctly, is that you can’t jump in the middle of a linked list. You start at the root and go to the next node then the next, etc. So you really can’t perform a binary search or any kind of hashing on the data.

The most popular variation of the Binary Tree is the Binary Search Tree (BST). BSTs are used to quickly and efficiently search for an item in a collection. Say, for example, that you had a linked list of 1000 items, and you wanted to find if a single item exists within the list. You would be required to linearly look at every node starting from the beginning until you found it. If you’re lucky, you might find it at the beginning of the list. However, it might also be at the end of the list, which means that you must search every item before it. This might not seem like such a big problem, especially nowadays with our super fast computers, but imagine if the list was much larger, and the search was repeated many times. Such searches frequently happen on web servers and huge databases, which makes the need for a much faster searching technique much more apparent. Binary Search Trees aim to Divide and Conquer the data, reducing the search time of the collection and making it several times faster than any linear sequential search.

not sure there are necessarily hard and fast rules for this, so this is more than opinion (to a large extent). Consider this hypothetical program. Suppose you have an address book and want to store People objects somehow so that you can retrieve information about the person (name, age, address, etc) Suppose the key is the person’s name. (snowz) Now, as you might imagine, people are going to want to get Sue Johnson, Albert Zudo, Michael Allan, etc. in any order. So, from the perspective of a program, the order you will be retrieving data will be random. IMO, a tree structure would be better here than a linked list. For a linked list to get to Albert Zudo you are going to have to retrieve the data by going through every entry before Albert Zudo (all A’s, B’s, etc) For a tree structure you can use a binary search (Binary search algorithm - Wikipedia, the free encyclopedia). A binary search essentially lets you eliminate half of the possible choices on each comparison. A linked list only lets you eliminate one.

Similarly with insertions, to add someone to the address book you can simply do a binary search to find the insertion point for a tree. For a linked list you have to go through each item to find it’s insertion points.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  HRM628 VU Current GDB No. 1 Spring April 2012 Solution required Vuhelper 1 3,676 07-22-2020, 08:06 PM
Last Post: Johnnieaunders
  MGT501 Human Resource Management GDB No. 2 Solution 23rd January 2016 Vuhelper 0 1,818 01-23-2016, 06:07 PM
Last Post: Vuhelper
  MTH302 Business Mathematics & Statistics GDB Solution 23rd January 2016 Vuhelper 0 1,683 01-23-2016, 03:39 PM
Last Post: Vuhelper
  STA630 Research Method GDB 2 solution 23rd January 2016 Vuhelper 0 1,989 01-23-2016, 03:15 PM
Last Post: Vuhelper
  MGT211 Introduction To Business GDB No 1 Solution Ideas Fall 2014 Vuhelper 0 1,669 12-04-2014, 03:20 PM
Last Post: Vuhelper
  MGT101 Financial Accounting GDB Solution and Discussion December 2014 Vuhelper 0 2,862 12-03-2014, 09:05 PM
Last Post: Vuhelper
  MGT201 Financial Management GDB No. 01 Solution Fall 2014 Last date is 4th Dec 2014 Vuhelper 0 2,474 12-03-2014, 03:58 PM
Last Post: Vuhelper
  MGT520 International Business GDB No. 01 Solution and Discussion Fall 2014 viki 0 2,587 12-03-2014, 03:03 PM
Last Post: viki
  GDB No 1 MGT301 Principles of Marketing Solution and Discussion December Fall 2014 viki 0 2,507 12-03-2014, 02:45 PM
Last Post: viki
  MGT602 Entrepreneurship GDB No 1 Discussion and Solution Fall 2014 Vuhelper 0 2,479 12-02-2014, 10:36 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)