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
use c++ to define a vector d = {2,2/2,2/3,2/4,2/5,.....,2/20000} as a valarray! please do not use a vector. please do not use pushback as that is only defined in vectors not valarrays.
Write a C++ program that takes rows and cols from user an dynamically declare a 2D array. Initialize thearray and then find the euclidean norm of the matrix.
In OCaml programming language, create a function printing_matrix val printing_matrix : bool array array -> unit, that given a bool matrix, it prints it on screen (true →”T”, false→”F”).
Chapter 6 Solutions
Data structures and algorithms in C++
Knowledge Booster
Similar questions
- 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.arrow_forward1. Write a functionSummOddthat will find the sum of all elements of odd ordera1+a3+...of a given a array. Pass an array arr[ ] and a dimension n and return the value of the suma1+a3+...asthe function’s return value. Call this function in themain()with arr[ ]={8,6,4,2,3,5}and dimensionn=6 to test the correctness of your general function. Keywords: Write function, pass array and dimension, return sum of odd orderarrow_forwardEvery vector can be normalisedarrow_forward
- Create a vector x with the elements: O, 1/2, 2/3, 3/4, 4/5,...arrow_forwardSuppose a computer program needs to apply an affine transformation to a complex three-dimensional object made up of 3000 points. The transformation is composed of 8 matrices (call them M1 through M3), so for each point (x, y, z) in the object, the following operation is performed. |-|-|-|-|| y M1 M2 M3 M7 M8 Each multiplication of a matrix times a column vector involves 16 multiplications (of one number by another) and 12 additions, for a total of 28 arithmetic operations. Each multiplication of a matrix times another matrix involves 64 multiplications and 48 additions, for a total of 112 arithmetic operations. (These numbers are not made up or chosen randomly; they are facts about 4 x 4 matrix multiplication.) The most inefficient way of applying the transformation to the 3000 points would be to begin on the left, multiplying M1 by M2, then that result by M3, and so on along the list from left to right, and doing the same 8 multiplications again for each of the 3000 points. How many…arrow_forwardWrite a function linear_independence that takes a collection of vectors with integer entries (each written as a list), and returns True if this collection of vectors is linearly independent, and False otherwise. Examples: linear_independence([1,2]) should return True. linear_independence([1,3,7],[2,8,3],[7,8,1]) should returnTrue. linear_independence([1,3,7],[2,8,3],[7,8,1],[1,2,3]) should return False.arrow_forward
- My questions is in this example I read from my R textbook: test_function = function(x) {x[x<0] = -x[x<0]return(x)} It is designed to return a negative number for all values in a vector, such that is you pass -3, -2, 2, 3 in, as such: test_function(c(-3,-2,2,3) The out put would be 3 2 2 3 My question is can you explain to me the logic of how this works?arrow_forwardWrite a user-defined function that determines the value that occurs most often in a set of data that is given in a two-dimensional matrix. For the func- tion name and arguments, use [v, q] =matrixmode (x). The input argu- ment x is a m×n matrix of any size with numerical values, and the output arguments v and q are the values that occur most often and the number of times they occur. If there are two, or more, values that occur most often than v is a vector with these values. Do not use the MATLAB built-in func- tion mode. Test the function three times. For input create a 5×6 matrix using the following command: x=randi (10,5,6).arrow_forwardHow to parallelize addition of the large vectorarrow_forward
- Write a program in C/C++ for multiplucation of two matrix usin array.arrow_forwardAssume that EMB(w) is the word embedding for a word, w, computed by some common technique for computing word embeddings (e.g., word2vec). Consider the vector obtained by the following vector arithmetic: EMB("Japan") + EMB("Paris") - EMB("Tokyo"). Other than the words that already related to this equation, what word's embedding would likely be close to the result? Briefly explain (in one sentence) your answer.arrow_forwardGiven a zero-based permutation nums (0-indexed), build an array ans of the nums[nums[i]] foreach @ buildArray(vector& nu}ns) : fest the function using the sample case given in main functio ms—{5,81234} : 14,5,0,1,2,3] Larrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education