Related questions
Concept explainers
Make a C++ program that incorporates recursion to solve the following problem. The
program has to compile and execute under the UNIX gcc or g++ environments.
For this program have it accept a sequence of k characters from the user and use the characters to produce a k concentric squares. Assuming an index origin of 1, the outermost square is made up of the letter a[k], the
square inside that is made from the letter a[k-1], the square inside that is made from the letter
a[k-2], and so on, with the innermost square made from the letter a[1]. For example, if k=5, and
the values of a are
("B","U","C","K","Y") then the executed program should display:
Y Y Y Y Y Y Y Y Y
Y K K K K K K K Y
Y K C C C C C K Y
Y K C U U U C K Y
Y K C U B U C K Y
Y K C U U U C K Y
Y K C C C C C K Y
Y K K K K K K K Y
Y Y Y Y Y Y Y Y Y
Please make main the first function in the program by protyping any other functions, and if possible make the concentric squares recursive situation its own class.
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 4 images
- Define a Python function split_dict() that takes a number x and a dictionary d whose keys are strings and values are numbers. It returns a tuple (d1, d2) of dictionaries of the same kind, where di consists of the key-value pairs of d whose values are less than or equal to x, and d2 consists of the key-value pairs of d whose values are greater than x. The following is an example execution.>>> d= dict([('a', 2), ('b', 10), ('c', 2), ('d', 9), ('e', 5)])>>> x = 3>>> print (split_dict (x, d)) ({'a': 2, 'c': 2}, {'b': 10, 'd': 9, 'e': 5})>>>arrow_forward4. Given the following recursive definitionseq(1) = seq(2) = 1seq(n) = 2 ∗ seq(n − 1) + 3 ∗ seq(n − 2)implement the corresponding program and use it to calculate seq(5).How many invocations are made to the function seq when calculating seq(5)?arrow_forwardCould I get an example of a program writen in C that uses qsort() to sort its command line vector argv by the length of the strings? This is part of my first project and I don't understand pointers very well. If you have a video on how it is done that would work too. I looked at the meterial provided to me and I still cant rap my head around it. If this is to big of a question if you could baby step me through how pointers work that would be a great help. Thank youarrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education