Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment - Implementation of Algorithms and Data Structures

Question 1.

a. Implement a generic Stack class using an array T[] for storing elements. Your class should include a constructor method, which takes as argument the capacity of the stack, push, pop and peek methods, and asize method which returns the number of elements stored. Implement dynamic resizing for this stack.

b. Write a program to test your implementation of this Stack class. You also need to provide at least 4 test cases for this program to test all the methods including constructor, push, pop, peek and size, and to test dynamic resizing.

Question 2.

a. Implement a genericQueue class that has enqueue, dequeue and peek methods and all of these methods must be O(1) time. This class also has a min methodwhich returns the minimum value stored in the queue, and throws an exception if the queue is empty. Assume elements are comparable. If the queue contains n elements, you can use O(n) space, in addition to what is required for the elements themselves.

b. Write a program to test your implementation of this Queue class. You also need to provide at least 4 test cases for this program to test all the methods including enqueue, dequeue, peek and min.

Question 3.

a. Implement a generic queueclass namedInefficientQueue in terms of twointernal stacks. The methods required in this class are enqueue, dequeue, andpeek. The goal of this problem is to get you to use the stack abstraction while implementing aqueue abstraction. This method for implementing a queue is quite inefficient (thus the name of the class). Why is this so?

b. Write a program to test your implementation of this queue class. You also need to provide at least 4 test cases for this program to test all the methods including enqueue, dequeue and peek.

Question 4.

Implement theRemoveBefore(int nodeValue) and RemoveAfter(int nodeValue) methods for aLinkedListclass.

The RemoveBefore (RemoveAfter) method removes the node before (after) the node having the given node value. The internal class Node to build the LinkedList class has only an integer value, nodeValue, and a single link, next, that links to the node just behind the given node. You also need to implement the Add(int nodeValue) method for the LinkedList class using the internal Node class.

Question 5.

a. Write a method that takes a sorted integer array A and a key k and returns the index of the first occurrence of k in A. Return -1 if k does not appear in A. For example, when applied to the array in Figure 12.1 below, your algorithm should return 3 if k = 108; if k = 285, your algorithm should return 6.

b. Write a Java program to test this method and provide at least 4 test cases for this program.

1666_Figure.png

References:

[1] Gayle Laakmann. Cracking the Coding Interview.

[2] Adnan Aziz, Tsung-Hsien Lee and Amit Prakash. Elements of Program Interviews.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91774875

Have any Question?


Related Questions in Computer Engineering

Question a topic related to database securityyou must pick

Question: A topic related to Database Security. You must pick one topic after reading at least 5 articles. You must provide a list of those articles you read and you must annotate each one. That is, you must write at lea ...

Suppose that the demand curve for tickets to see a football

Suppose that the demand curve for tickets to see a football team play a game is given by Q = 80,000 - 40P and marginal cost is zero. The team's stadium can host 75,000 fans. 1) How many tickets would the team sell if it ...

When is a subclass a subclasswhen programming or solving

When is a Subclass a Subclass When programming, or solving any sort of problem for that matter, abstraction plays a key role in the decision-making process. It allows you to remove irrelevant details in order to understa ...

Regards to cin what programming situations would the use of

Regards to C++ In what programming situations would the use of an array be beneficial? What situations would not warrant the use of an array? Provide an example showing why. Research the concept of C++ vectors. Describe ...

Fiona told her friend that she is very fortunate as the

Fiona told her friend that she is very fortunate as the slow-down in the economy has not decreased sales in her grocery store by much compared to sales of new cars in his car dealership. Explain what Fiona meant using th ...

Determine whether or not the following claim is true for

Determine whether or not the following claim is true for all regular expressions r 1  and r 2 . The symbol ≡ stands for equivalence regular expressions in the sense that both expressions denote the same language.  (a) (r ...

Recently a government department is involved in the

Recently, a government department is involved in the development of an Online Passport Application Platform. The officers in the department are clear about the requirements of this platform. Besides, the functions of thi ...

Subject digital securityprovide an fidm authentication

Subject : Digital Security Provide an FIdM authentication system that you have used (being subjet to). Tell the name of the organizations acted as the IdP (Identity Provider) and SP (Service Provider)?

Question imagine that you are hired as a cio of a quickly

Question: Imagine that you are hired as a CIO of a quickly growing retail chain with an online presence. You have growing transactional databases but want to build a business intelligence infrastructure. You also have va ...

Systems and networkscalculate the timeoutinterval for tcp

Systems and Networks Calculate the TimeOutInterval for TCP. Assume the observed SampleRTTs for the first three packets are 2 seconds, 5 seconds, and 8 seconds. The value of a=0.25 and the "safety margin" is 0.5 seconds. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As