This competency assessment assesses the following Outcome(s):
IT391M1-1: Apply the common linear structures of lists, stacks, and queues.
Module Outcomes:
Analyze recursion as a problem-solving procedure.
Apply problem-solving procedures to solve data structure and algorithm problems.
Differentiate the removal process between stacks and queues.
Explain the relationship between stacks and queues and the underlying data
structure.
Implement a stack or a queue.
This assessment consists of two assignments as detailed below:
Assignment 1
Purpose
The purpose of assignment 1 in this assessment is to study and practice implementing
recursion to solve problems of a repetitious nature.
Assignment Instructions
Assignment 1
In Section 1, the student is provided example code
This assignment has two sections that will be written as two sections of the same program.
In Section 1, the student is provided example code. The student will take the example code,
into a program in the IDE corresponding to the language path they have chosen, execute
the code successfully, and produce the correct output.
For Section 2, the student will write the code without the aid of a supplied example code.
Both sections of assignment 1 will be placed in a single program.
The beginning of each section will be delineated with the following comment block. Be sure
to insert the correct values for the section number.
*************** *********
**************************
//****Assignment #, Section #
*********************************************************
Assignment Sections Detailed
Section 1:
L
1. Add your section comment to the code.
2. Print a blank line./n3. Print *********** Section 1 **********"
4. Print a blank line.
5. Create a method called Fibonacci which will recursively calculate the Fibonacci
sequence for the number passed to it.
6. Call the Fibonacci method and pass it the value 10.
Section 2:
1. Add your section comment to the code.
2. Print "********** Section 2 ***********
3. Print a blank line.
4. Create a method called factorial which will recursively calculate the factorial of an
integer value passed to it.
5.
Create a for loop to use the factorial method to find and print the factorials of every
number from 1 to 4.
6. When printing the factorial values, print them showing the number and its factorial.
For example, the factorial of 4 would be printed as 4! = 24
Assignment 2
Purpose
The purpose of assignment 2 in this assessment is to study and practice the implementation
of the queue and stack data structures.
Assignment Instructions
Assignment 2
The student will take the example code
This assignment has two parts, A and B. In Part A, the student is provided example code
consisting of several sections. The student will take the example code, place it into a single
program in the IDE corresponding to the language path they have chosen, execute the code
successfully, and produce the correct output.
Part B consists of several sections. Each section will create and manipulate a data
structure. The student will complete a single program for Part B, separate from the program
created for Part A.
In both Part A and Part B programs, the beginning of each section will be delineated with
the following comment block. Be sure to insert the correct values for the section number
and program.
//***************
***********
************
//**** Assignment #, Part (A or B), Section #
**************************** ******
L
****************/nPart A Sections Detailed
Section 1:
1. Add your section comment to the code.
2. Print "********** Section 1 ***********
3. On a new line, request the user to enter a word.
4.
Create a stack structure.
5.
Create a method called revString() which will accept a string value as input, use a
loop to push each character of the string value onto the stack structure, and then pop
each off in reverse.
6. On a new line, print "Your word in reverse is:" followed by the reversed word.
Hint: If the user entered "part" the reverse of "part" is "trap". (Obviously, not all words will
spell a real word in reverse.)
Section 2:
1. Add your section comment to the code.
2. Print "********** Section 2 ***********
3. Print a blank line.
4. Create a queue structure named 'shoppers' and load it with the names "Jane," "Bob,"
"Liza," "Tom," and "Mary."
5. On a new line, print "The number of shoppers at the grocery store is," followed by the
number of names in the queue.
6. On a new line print "The first shopper in line is," followed by the name of the first
person in the queue.
7. Add "Stephen" and "Ellen" to the queue.
8. Remove three more shoppers from the queue.
9. On a new line, print "The number of shoppers now in line is," followed by the current
number of shoppers in the queue.
10. On a new line, print "The shopper currently first in line is," followed by the name of
the person first in line in the queue.
Part B Sections Detailed https://mail.google.com/mail/u/0/#inbox
Reminder: Part B of this assignment should be a separate program from Part A.
Section 1:
1. Add your section comment to the code.
2. Print*********** Section 1 ***********
3. Print a blank line.
L
4. Create a queue structure and add the following people in this order, "Jim," "Bob,"
"Susan," "Liz," and "Alex."
5. On a new line, print "The number of people in line at the bank is," followed by the
number of people in the queue.
6.
On a new line, print "The names of those in line at the bank are," followed by the
names in the queue in order without removing them from the queue./n7. On a new line, print "The first customer in line is," followed by the name of the first
customer in line. Remove the customer from the queue.
8. Add "Andy" and "Rhonda" to the queue.
9. Remove three more people from the queue.
10. On a new line, print, "The number of customers in line now is," followed by the
number of people in the queue.
Section 2:
1. Add your section comment to the code.
2. Implement a stack structure.
3. Print a blank line.
4. On a new line, print ************ Section: 2 ************ to the console.
5. Print a blank line.
6. On a new line, print, "Please enter a sentence."
7. Add each word of the sentence to the stack.
8.
Remove each word and print it on a new line so that the words are readable but the
sentence is written in reverse.