Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
Question
Book Icon
Chapter 7, Problem 25C
Program Plan Intro

Program Plan:

1. Below mentioned variables are used:

  • ArrayList-integer array List
  • size- capacity of array List.
  • front- Index 0 of array.
  • rear-end of array.

2. Below Mentioned functions are used:

  • enQueue()-toinsert the element in a circular array list
  • deQueue()-to delete the rear element.
  • displayQ()-display the elements of queue.
  • main()-main function in program that reads the input from user anddisplays the output.

Program description:

This program is for creating a circular array list which has a constant capacity. Since this is a circular array the front and rear positions are the same. So insertion of an element or deletion if an element need not requires a loop.

Blurred answer
Students have asked these similar questions
In an array-based implementation of a List, why does the add operation take O(n) time in the average case? Select one: a. The time it takes to shift entries over to make room in the array depends on the number of entries in the List b. The time to copy the current entries into a newly allocated, larger array depends on the number of entries in the List c. The time to access the position in the array to add the new entry depends on the number of entries in the List d. The time to access the position in the array to add the new entry depends on the capacity of the array
Write and implement a recursive version of the binary search algorithm. Also, write a version of the sequential search algorithm that can be applied to sorted lists. Add this operation to the class orderedArrayListType for array-based lists. Moreover, write a test program to test your algorithm.
For each problem, please provide Describe the worst-case input (the input that would cause the largest running time) Summation used to calculate number of steps for the worst case Explanation of how the code relates to the summation a. (loops require discussing number of iterations and steps per iteration) b. (recursion requires a diagram) A O bound i. i. ii. iv. static Integer sum(List a) { if (a.size() == 0) { return 0; } else if (a.size() == 1) { return a.get(0); } else { a.size()/2; int rightLen = a.size() - leftLen; int leftLen List aLeft List aRight (); (); %3D new new %D for (int i=0; i

Chapter 7 Solutions

Data Structures and Algorithms in Java

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education