Write an algorithm in pseudo code

User Generated

thnvthnv123

Computer Science

CIS 334

Towson University

Description


Unformatted Attachment Preview

4. Write an algorithm in pseudo code to insert one element in a singly linked list before a given element. Your algorithm will print the original list, request the user to put in an element to be inserted, and an element to indicate the location of the insertion, then print the final list after the insertion is done. If the element doesn't exist in the list, add the new element to the end of the list. (5 points). Use the following as your test cases to evaluate whether your algorithm works correctly: if you have a linked list: 3->1->0, with user input 5 and 1, your list should become 3->5->1->0; with user input 5 and -1, your list should become 3->1->0->5. 5. Write an algorithm to check whether a given string is a palindrome. If a string reads the same backwards as forward (ignore the spaces, case not sensitive), we call the string as palindrome. For example, “madam” is a palindrome while “car” is not. Write your algorithm in pseudo code, then implement it in C++/Java. Your algorithm must involve explicit use of both a stack and a queue. Make sure to test your program with at least "Was it a car or a cat I saw" and "cartrac". (6 points):
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

Hello check the document which has the program and the algortihms

4. An algorithm in pseudo code to insert an element in a single linked list before a given

element
Known as Singly linked list can be termed as a nodes each having at least 2 numbers. Simply, it is
a sequence of nodes. One of the number point to the next node while the other holds the actual
data as shown.

Singly linked list are unidirectional, that is ...


Anonymous
This is great! Exactly what I wanted.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags