Download Practice

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
CSSE 152 Fundamentals of Computer Science II
PRACTICE ON RECURSION & LINKED LISTS
1. Write a program that accepts some unknown number of positive integers with ZERO
signifying the end of input and that will compute AND output, in reverse, the average
value of each pair of numbers. You may assume that all input is correct. Do not use
linked lists and/or arrays! This calls for a RECURSIVE procedure or function.
2. Write a program that accepts integers as data (file or keyboard, your choice) and
creates a linked list in non-decreasing order. Then prompt the user for an integer and
remove all occurrences of that integer from your linked list. Do not lose any other
elements!
3. Write a program that accepts integers as data (file or keyboard, your choice) and
creates an unsorted linked list. Then write a recursive routine to display the LAST
occurrence of a negative integer in the linked list.
4. Using the program written for #3, sort the linked list in non-decreasing order. The
point is to sort a list that already exists.
5. Using the program written for #2, replace each node in the linked list that contains a
positive even integer x with two nodes, each containing the integer value x/2.
Maintain the ordered property of the list! For instance, the list (-4, -2, 0, 1, 2, 6, 7, 8,
17, 32, 88) becomes (-4, -2, 0, 1, 1, 1, 3, 3, 4, 4, 7, 16, 16, 17, 44, 44).
6. Write a program that accepts some unknown number of positive integers with ZERO
signifying the end of input. Write a recursive procedure that will store the LAST 20
values in an array. After the recursion terminates, output the contents of the array (in
any order) AND display the average value of the last 20 integers. You may assume
that all input is correct AND that at least 20 values are input.
Related documents