Data structures and algorithms in C++
2nd Edition
ISBN: 9780470460443
Author: Goodrich
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Question
Chapter 6, Problem 12C
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.
- rank- position of element to find.
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.
- elementAtRank() − returns the value of element in position rank.
- 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.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Demonstrate how to use pop_back function in vector C++.
Given vector<int> v ={1,7,9,3,5,8}.
Remove last element in the vector using pop_back and print the vector.
Declare an array X of type 2 dimensional, such that the first index can take values 0 to 9 and the second can take values 0 to 12. Also, the input for each dimension should be taken separately in 2 functions.
In OCaml, write a function printmat : bool array array -> unit = that given a bool matrix it prints it on screen with ones and zeros, instead of true and false.
Chapter 6 Solutions
Data structures and algorithms in C++
Knowledge Booster
Similar questions
- This a dynamic programming problem where the solution to each possible subset is stored in OPT[i, j] (inside a 2D array). Can someone assist in helping me solve it this way?arrow_forwardWrite a program in C/C++ for multiplucation of two matrix usin array.arrow_forwardWrite a partition function of a dynamic array. the first element of the array should be the pivot. Code needed in c++.arrow_forward
- Write a C++ program that uses multi-dimensional array. Take user input to enter number of elements in a matrix and find transpose of that matrix.arrow_forwardUse Ocaml! Write a map function that takes a function and an array.The map function modifies the elements of the array with values from applying the function. val map : ('a -> 'a) -> 'a array -> unit = <fun> Write code to demonstrate that it works.arrow_forwardDemonstrate how to use push_back function in vector C++. Given vector<int> v ={1,7,9,3,5,8}. Push another element 10 in the vector and print it.arrow_forward
- Implement the truncate function that is passed two parameters, a vector of floats (passed by ref) and a float max number (by value). Truncate (replace by the maximum value) all elements from the vector that are larger than the max value parameter. in C++arrow_forwardCreate a vector data type to be used with the sorting methods to arrange multidimensional vectors of d integers in ascending order by first component, descending order by second component for vectors with equal first component, ascending order by third component for vectors with equal first and second components, and so on.arrow_forwardWrite MATLAB expression to do the following: A. Evaluate the maximum value in the vector resulting from element-by-element multiplication of the second column of B with the 1st column of A. B. Use element-by-element division to divide the 1st row of A by the 1st three elements of the third column of B. evaluate the sum of the elements of the resulting vector.arrow_forward
- Implement a range function for a dynamic array which returns a new dynamic array that is a subset of the original. input parameters: array - (the array and any related parameters) start - index of the first elementend - index of the last elementInterval - An integer number specifying the incrementation of index This function returns a new dynamic array containing the elements from the start thru the end indices of the original array.All array indexing must be done using pointer arithmetic. For example, given the array: 49 96 99 47 76 29 22 16 30 22 If the start and end positions were 5 and 9 with step 2, return a new dynamic array: 29 16 22 Please use following main to test your function. int main(){int *p = new int[10]{49,96,99,47,76,29,22,16,30,22}; int *q = range(p,10,5,9,2);for(int i=0;i<3;i++) cout<<q[i]<<" "; // print 29 16 22 cout<<endl;delete [] q;q = range(p,10,1,8,3); for(int i=0;i<3;i++)cout<<q[i]<<" "; // print 96 76 16 cout<<endl;…arrow_forwardCan you help with with the following questions, regarding population genetics and the Wright Fisher model in python? 1. Go through the given WFtrajectory function and give a short explanation of what each line of code does. Pay attention to the variables in the function and explain what they contain. 2. Make a new version of the WFtrajectory function which does exactly the same thing except that instead of appending to a list it initialises a numpy vector with zeroes and fills the vector with a for loop instead of a while loop. Make a plot of the output from a few example trajectories.arrow_forwardImplement a generic C++ function for binary search that given a sorted array (or vector) of items and an item toBsearched, returns the index of toBsearched in the array/vector if it exists and -1 otherwise.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Operations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole