algorithm of this question with proper explanation: 1. Use a list (not necessarily a linked list) to store few items of a vending machine. Each item will have a name, item id and cost. How can the...

algorithm of this question with proper explanation:

1. Use a list (not necessarily a linked list) to store few items of a vending machine. Each item will have a name, item id and cost. How can the machine manage the sale of an item for which the input amount is given by the user? The user will input some currency to the machine followed by the cost of the item and the machine will dispatch the desired item on the basis of its cost.






2. A set can be represented as a bit sequence such that the length of the sequence is equal to the number of items in the universal set and the value 1 represent the presence whereas the value 0 represents the absence of an element. For example the set {1,3,4,5} can be represented as 1011100000 for the positive numbers from the universal set containing 10 elements. Represent the set by bit sequence using appropriate data structure (array/list/hash table etc.). If two such sets are given, how can the union and intersection operations could be performed?






3. Consider the following pair representing a list of data items: (item, weight), e.g., (x,w1), (y,w2), (z,w3) etc. The items are to be processed on their priority values which is the value of weight for each item. New items will be added to the list regularly and processed as per their priority value- higher the weight, lower its priority is. The case of tie will be managed by some appropriate condition by the programmer. The processed items will be deleted as soon as it is processed. Implement such a list with 'add' and 'process' (delete) operations using two different data structures. Discuss the suitability of the data structure for the above description and estimate the complexity of 'process' operation using suitable asymptotic notations.






4. Estimate the longest path in a given weighted graph. Represent the graph using appropriate method and show all the edges in a sequence (the path) representing the longest path. Estimate its time complexity.






5. Implement an interpolation search for a dictionary. The interpolation search is an enhancement of the binary search where the key element is searched in a similar way to the searching a dictionary where some key is searched not from the mid point but from appropriate and approximate position. For example, to search some word from 'e', the dictionary is searched from the point near to beginning of the dictionary. Similarly, the word starting from 'p' is searched after the mid of the dictionary but not from to the mid point of the right half
May 11, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here