CS 4337- Spring 2023- Assignment#1
.pdf
keyboard_arrow_up
School
Southern New Hampshire University *
*We aren’t endorsed by this school
Course
4337
Subject
Computer Science
Date
Dec 6, 2023
Type
Pages
2
Uploaded by SuperHumanCrowMaster636
CS/CE 4337 - Assignment#1
Due Date: 2/10/23, 11:59 pm
1-Draw the internal representation for the following lisp list(s).
•
(cons '( ((apple () orange ()) ( (( () orange))) banana)) '() )
•
(cons '( () (( apple(((( (grape)()))) banana ()))) orange ) '((apple)) )
•
(cons '( ((()apple ()) orange (grape ()) banana)) '(apple) )
2-Determine the output of the following functions (You must show your works)
•
(cdaar '( ((orange grape((orange grape) apple () ()) banana)) apple banana))
•
(cddaar '( ((orange grape((orange grape) apple () ()) banana)) apple banana))
•
(cadadr'( orange ((()) (grape () (apple)) banana)))
3-Give combinations of cars and cdrs that will pick 7 from each of the following
lists ,(1 (2 3) 7), (((1 (7)))), and (1(2(3(4(5(6(7)))))))
4-Fully explain each predict in the following scheme function. Then
manually
trace
the function with the given input. Please study provided examples in the
lecture notes to learn how you should manually trace our procedure.
5-The following scheme function takes a tree (represented as a list) and returns a
list whose elements are all the leaves of the tree arranged in right to left order.
For example, ( leaves '(((1) (2)) ((1 2) (3 4))) )
returns
‘(2 1 4 3 2 1). Fully ex-
plain each predict in the following scheme function. Then
manually trace
the
function with the given input.
CS/CE 4337-Spring 2023- Assignment#1
1
6-Fully explain each predict in the following scheme function. Then
manually
trace
the function with the given input.
7-Fully explain the following scheme function. Then,
manually trace
the function
with the given input.
8-The following pattern of numbers is called Pascal’s triangle.
The numbers at the edge of the triangle are all 1, and each number
inside the triangle is the sum of the two numbers above it. Write a
procedure that computes elements of Pascal’s triangle by means of a
recursive process.
Note: Your function should produce 5 rows of
Pascal’s triangle and should return (1 2 4 8 16) as
sum of elements
for each row
9-Define a scheme procedure that takes a set (a list of distinct elements) and
generates a list of all subsets of the set. For example, (subsets '(a b c )) returns
((a b c) (b c) (a c) (c) (a b) (b) (a) ()). Then, Manually trace your procedure with
the provided example. Please study provided examples in the lecture notes to
learn how you should manually trace our procedure.
CS/CE 4337-Spring 2023- Assignment#1
2
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Haskell Textbook: "Programming in Haskell, 2ndEd.", by Graham Hutton
Programming in Haskell:
data Tree a b = Leaf a | Branch b (Tree a b) (Tree a b)
Implement the three functions that traverse the tree inthe given order collecting the values from the tree nodes into a list:preorder :: (a -> c) -> (b -> c) -> Tree a b -> [c]inorder :: (a -> c) -> (b -> c) -> Tree a b -> [c]postorder :: (a -> c) -> (b -> c) -> Tree a b -> [c]
Also, show how each of your three functions work step-by-step with the following tree object.tree1 :: Tree Int Stringtree1 = Branch "+"(Branch "*"(Leaf 3)(Branch "+" (Leaf 4) (Leaf 5)))(Branch "+"(Branch "*" (Leaf 6) (Leaf 7))(Leaf 8))Notice that the data type Tree can store different types of values in the leaves than onthe branching nodes. Thus, each of these functions takes two functions as arguments: Thefirst function maps the values stored in the leaves to some common type c, and the secondfunction maps the values…
arrow_forward
Implement a complete class in c ++ code that represents a stack. The stack must contain the operations push and pop with ordinary semantics. Both operations must be 0 (1).
arrow_forward
Write a lisp function f9 that removes duplicates from a list. Example: (f9 ‘(c (a b) c d (a b))) returns (c (a b) d)
should mainly just use cond car and cdr
arrow_forward
Implement a complete class in c ++ code that represents a stack. The stack must contain the operations push (e) and pop (): e, with standard semantics. Both operations must be 0 (1).Your only restriction is that you may not use the class <T> from std ::
arrow_forward
Implement a complete class in c ++ code that represents a stack. The stack must contain the operations push (e) and pop (): e, with standard semantics. Both operations must be 0 (1).
arrow_forward
Write a LISP function f10 that finds the intersection of two lists. The intersection meansthe common elements of the two lists. Example: (f10 ‘(a (a b) c d) ‘(b(a b) d)) returns ((a b) d)
CAN ONLY USE CAR AND CDR AND RECURSION SETQ AND DO LIST CANT BE USED
arrow_forward
2. Implement a Reference-Based ADT Stack and verify "isEmpty()", "push()", "pop()", "popAll()", and "peak()" operations.
arrow_forward
1. fast please in c++
arrow_forward
write in c++
Given a class declaration for a list implemented using a linked list (like NumberList) implement some of the functions (like the constructor, the destructor, append a node to the end, remove the last node, remove the node in position i, etc).
arrow_forward
Please help with C++ graph question in C++ language. Thank you.
arrow_forward
implement the following methods in C language using stack:
push(),pop(),peak(), isEmpty().
Use of pointers is not allowed.
arrow_forward
Question 1:Convert a decimal to binary and binary to decimal using recursionTest your implementation with following examples:● (1947)10 = (11110011011)2● (1992)10 = (11111001000)2● (2021)10 = (11111100101)2Question 2:Implement a member function that prints a singly linked list in reverse order without creating acopy or changing the original List.void printBackwards() constQuestion 3:Implement a recursive member function “isSorted” which recursively checks whether the linked listis sorted (ascendingly).bool isSorted() constQuestion 4:You will implement a function bool Equalize_Occurrences (char key, int maxcount) of theclass list, that will take a character key and maximum count for the consecutive occurrences of thekey inparameters. It will then traverse the list, verify and update the consecutive occurrences of the keyaccordingto maximum count and returns true. It returns false if no occurrence of key is found.Note: You can traverse the list only once for this task.
arrow_forward
** Write in Lisp ***
arrow_forward
A-
Declare a self-referential structure
for a linked list having one data
StudentNode
field called GPA (float), and one pointer to
StudentNode called next.
B-
Write a non-recursive function
-
that counts all the GPAS that are less than or
equal to 2 in your linked list starting from the
head of the list.
Example: If the list is 1.9->2->3.5->4->1.8, the
function should return 3.
C-
Write a recursive function that
prints all the GPAS that are higher or equal to 3.5
in your linked list starting from the head of the
list.
Example: If the list is 1.9->2->3.5->4->1.8, the
function should print: 3.5->4.
arrow_forward
solve the attached c++ program and fullfill all reqirements
arrow_forward
write in c++
Define the 3 bolded functions for the following DynIntStack (linked list):
class DynIntStack {private: struct Node { int value; // Value in the node Node *next; // Pointer to the next node }; Node *top; // Pointer to the stack toppublic: DynIntStack() { head = nullptr; } void push(int); //assume this is already defined void removeTop(); // removes the top element without returning it int topValue(); // returns the top element without removing it bool isEmpty() { return head == nullptr; } bool isFull() { return false; } void pushMany(int values[], int n); //add n values from the array};
Hints:
void removeTop() (hint 3 lines of code)
int topValue() (hint 1 line of code)
void pushMany(int values[], int n) (hint 2 lines of code, use a for loop, call another function)
arrow_forward
Write a C++ program that implements a linked list as an abstract data type. The program must:
Be type flexible, that is, could be a list of integers, string, or any type.
allow the user to add members into the list
delete members from the list
make sure the list is still sorted after all the deletion and addition
Show all the function implementation.
arrow_forward
This is assignment used C++.
Develop a linked-list processing function, IsolateTargetSoloAsTail, to process a linked list as follows.
●
If a target cannot be found on the given list, a new node containing the target is created and added to the list's end (made the new tail node).
►
This includes the case where the given list is empty, in which the new tail node added is also the new head node. (This is so because the only node in a 1-node list is the list's head and tail node.)
●
If the target appears only once on the given list, the target-matching node is moved to the list's end (made the new tail node).
►
Nothing needs to be done if the target-matching node is already the tail node (of the given list).
●
If the target appears multiple times on the given list, the first target-matching node is moved to the list's end (made the new tail node), and all other target-matching nodes are to be deleted from the list.
►
Note that although…
arrow_forward
Create a stack class In java using an array.
The stack class must be created for sratch and no libraries can be used such as util*
arrow_forward
3. Write a LISP function, call it "count", of two
arguments, an atom x and a list L of sub-lists, which
returns the number of sub-lists in L that contain the
atom x. Use recursion.
example:
> (count 'b ( (ab c) (b c d) (c a) (d ab c)) ).
Returns: 3
> (count 'd '((a b) (b) (c a)))
Returns: 0
arrow_forward
In Java,
Define each of the following terms :
(i) List
(ii) Collection
(iii) Load factor
(iv)Comparator
(v) Maps
2b. Discuss your understanding of Sets in Java.
arrow_forward
Please help with C++ graph question in C++ language. Output also in image. Thank you.
arrow_forward
In C++, I need help to implement a Breadth-First Search (BFS).
a) Display the adjacency list representation of the graph
b) Display the list of colors. The colors used should be in the following order:
{Blue, Brown, Green, Lavender, Orange, Pink, Red, Yellow, Violet, Gold, Gray, Indigo, Silver}
c) Create a BFS tree and display the tree.
arrow_forward
Write C++ Class for Doubly linked list DList (Class for Node and a Class for DList) where class DList should had methods - Constructor and Destructor [Starting with head null] with their definitions - Insert Method [insert a new node at a particular position| with its definition Other methods are neglected.
arrow_forward
QUESTION:
NOTE: This assignment is needed to be done in OOP(c++/java), the assignment is a part of course named data structures and algorithm.
A singly linked circular list is a linked list where the last node in the list points to the first node in the list. A circular list does not contain NULL pointers.
A good example of an application where circular linked list should be used is a items in the shopping cart
In online shopping cart, the system must maintain a list of items and must calculate total bill by adding amount of all the items in the cart,
Implement the above scenario using Circular Link List. Do Following:
First create a class Item having id, name, price and quantity provide appropriate methods and then Create Cart/List class which holds an items object to represent total items in cart and next pointer Implement the method to add items in the array, remove an item and display all items.
Now in the main do the following
Insert Items in list
Display all items.
Traverse…
arrow_forward
2 pts
2/5
Animo Space Support
2D-DP-7
void mysteryFunction(int myList[][5], int r, int c)
{ int i, j, k, curr, temp;
for ( (1) )
for (i = 0; i < c; i++)
curr = i;
for (j = i; j < c; j++)
if(_(2)_)
curr = j;
temp =
myList[k][i];
myList[k][i] = myList[k][curr];
myList[k][curr] = temp;
int main()
int i,j;
int input[2][5] = {
{7, 2, 3, 15, 8},
{56, 4, 12, 5, 9}};
mysteryFunction(input, 2, 5);
for (i = 0; i < 2; i++)
{
for (j = 0; j < 5; j++)
printf("%d ", input[i][j]);
printf("\n");
return 0;
Output:
2 378 15
459 12 56
Given the code segment above, what should be the content of _(2)__ in order to achieve the provided output?
Assume the necessary libraries and functions are included and implemented.
arrow_forward
Define the function (doubleBubbleLst lst). This function should resolve to a list of sublists, where each sublist holds a single element from lst and all sublists from lst are also bubbled, so that every list and sublist has no atoms. This is the deep recursion version of bubbleLst.
For example: (doubleBubbleLst '(1 2 (3 4)) ) resolves to '((1) (2) (( (3) (4) ))).
arrow_forward
Stack ADT
Implement a program in C++ that has the following three parts and each does the following:
1. Implements in C++, the specification of a Stack ADT with all the Main and Helper behaviors (save the file as StackADT.h)
2. Implements in C++, all the necessary methods (behavior) of the StackADT (save the file as StackADT.cpp)
3. Implements in C++, a main function (the client or application program) that creates and uses Stack objects (save the file as StackMain.cpp). This
main function should be able to do the following:
a. It should be able to read a given text file as input,
b. It should be able to get each input value from the input file (one word at a time) and store it (push) on the StackADT object until it stores all
the words from the input file.
c. It should be able to retrieve an item from the stack and 1) display it on the screen, as well as 2) write it to an output file, and then delete (pop)
that item from the stack, and repeat this process until it retrieves all the…
arrow_forward
write a c++ program attached below using the concept of doubly linked list
arrow_forward
Write an abstract data type for queues whose elements store 10-characternames. The queue elements must be dynamically allocated from theheap. Queue operations are enqueue, dequeue, and empty. Use eitherC++, Java, C#, or Ruby
arrow_forward
Write code in C++ using linked list
arrow_forward
Question 6
Linked Lists lend themselves easily to recursive solutions. and it is common to traverse a list by processing a single element and
then recursively calling the function on the remaining sub-list. Il does this by accepting a pointer to the current position in the list es
a parameter. In the answers below. this has been referred to as the list pointer.
what criteria is oten used as the base case that ends the recursion and allos the function to return to he original cal?
The data element of the nade pointed to by the list pointer is storing-1.
The list pointer points to the beginning of the ist.
The list pointer is NULL
None of the above.
Question 7
when designing the Node structure for our linked list which attributes should we include? Select all that apply.
A deta element to store whatever the list is supposed to store.
A Node pointer to serve as the head of the list.
© A Node pointer to the next element in the list.
None of the above.
arrow_forward
Convert the following infix expression into its prefix and postfix equivalents:
a / b - (c + d * e) / f
*
For any postfix, show the final transformed expression using the stack method for
transformation as explained in class showing all the relevant steps.
For the prefix, show any needed reversion and the final transformed expression using
the stack method for transformation as explained in class showing all the relevant
steps.
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
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
Related Questions
- Haskell Textbook: "Programming in Haskell, 2ndEd.", by Graham Hutton Programming in Haskell: data Tree a b = Leaf a | Branch b (Tree a b) (Tree a b) Implement the three functions that traverse the tree inthe given order collecting the values from the tree nodes into a list:preorder :: (a -> c) -> (b -> c) -> Tree a b -> [c]inorder :: (a -> c) -> (b -> c) -> Tree a b -> [c]postorder :: (a -> c) -> (b -> c) -> Tree a b -> [c] Also, show how each of your three functions work step-by-step with the following tree object.tree1 :: Tree Int Stringtree1 = Branch "+"(Branch "*"(Leaf 3)(Branch "+" (Leaf 4) (Leaf 5)))(Branch "+"(Branch "*" (Leaf 6) (Leaf 7))(Leaf 8))Notice that the data type Tree can store different types of values in the leaves than onthe branching nodes. Thus, each of these functions takes two functions as arguments: Thefirst function maps the values stored in the leaves to some common type c, and the secondfunction maps the values…arrow_forwardImplement a complete class in c ++ code that represents a stack. The stack must contain the operations push and pop with ordinary semantics. Both operations must be 0 (1).arrow_forwardWrite a lisp function f9 that removes duplicates from a list. Example: (f9 ‘(c (a b) c d (a b))) returns (c (a b) d) should mainly just use cond car and cdrarrow_forward
- Implement a complete class in c ++ code that represents a stack. The stack must contain the operations push (e) and pop (): e, with standard semantics. Both operations must be 0 (1).Your only restriction is that you may not use the class <T> from std ::arrow_forwardImplement a complete class in c ++ code that represents a stack. The stack must contain the operations push (e) and pop (): e, with standard semantics. Both operations must be 0 (1).arrow_forwardWrite a LISP function f10 that finds the intersection of two lists. The intersection meansthe common elements of the two lists. Example: (f10 ‘(a (a b) c d) ‘(b(a b) d)) returns ((a b) d) CAN ONLY USE CAR AND CDR AND RECURSION SETQ AND DO LIST CANT BE USEDarrow_forward
- 2. Implement a Reference-Based ADT Stack and verify "isEmpty()", "push()", "pop()", "popAll()", and "peak()" operations.arrow_forward1. fast please in c++arrow_forwardwrite in c++ Given a class declaration for a list implemented using a linked list (like NumberList) implement some of the functions (like the constructor, the destructor, append a node to the end, remove the last node, remove the node in position i, etc).arrow_forward
- Please help with C++ graph question in C++ language. Thank you.arrow_forwardimplement the following methods in C language using stack: push(),pop(),peak(), isEmpty(). Use of pointers is not allowed.arrow_forwardQuestion 1:Convert a decimal to binary and binary to decimal using recursionTest your implementation with following examples:● (1947)10 = (11110011011)2● (1992)10 = (11111001000)2● (2021)10 = (11111100101)2Question 2:Implement a member function that prints a singly linked list in reverse order without creating acopy or changing the original List.void printBackwards() constQuestion 3:Implement a recursive member function “isSorted” which recursively checks whether the linked listis sorted (ascendingly).bool isSorted() constQuestion 4:You will implement a function bool Equalize_Occurrences (char key, int maxcount) of theclass list, that will take a character key and maximum count for the consecutive occurrences of thekey inparameters. It will then traverse the list, verify and update the consecutive occurrences of the keyaccordingto maximum count and returns true. It returns false if no occurrence of key is found.Note: You can traverse the list only once for this task.arrow_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