EBK DATA STRUCTURES AND ALGORITHMS IN C
EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
bartleby

Concept explainers

Question
Book Icon
Chapter 4, Problem 1PA
Program Plan Intro

Program Plan:

  • In “main()” function
    • Declare variables “stackk1” and “stackk2” for two stacks and “char_ele” for character of string.
    • Initializing length of string “lengthh” and flag to check palindrome “flag_palleo” as “0”.
    • Read each character of string from keyboard and push it into “stackk1” and increment “lengthh” by one.
    • If length of string “lengthh” is even, pop half number of characters from “stackk1” and push it into “stackk2”.
    • If “lengthh” is odd, pop half number of characters from “stackk1” and push it into “stackk2”.And pop middle character of string from “stackk1”.
    • For half number of characters in string, compare tops of both stacks. If both are same then pop top of both stacks.
    • If tops of two stacks are not same, set flag value as “1” and break from loop.
    • Finally check the value of flag. If flag value is “1”, print the message that string is not palindrome.
    • If flag value “0”, print the message that string is palindrome.

Blurred answer
Students have asked these similar questions
Use stacks from the STL to implement a video game library functionality. In this implementation, consider a VideoGame class with title, release year, genre and publisher as variables. Provide setters and getters to these variables.  In main, create a stack of video games. Add 5 different game objects into the stack. Then in a loop, for each item that you retrieve from the stack display the game information as follows:   TITLEYEARGENREPUBLISHER
Write a java method to search for an element in an array using a linear search. Many list processing tasks, including searching, can be done recursively. The base case typically involves doing something with a limited number of elements in the list (say the first element), then the recursive step involves doing the task on the rest of the list. Think about how linear search can be viewed recursively; if you are looking for an item in a list starting at index i:o ¬If i exceeds the last index in the list, the item is not found (return -1).o ¬If the item is at list[i], return i.o ¬If the is not at list[i], do a linear search starting at index i+1
Python please...   Implement a function printIndex() that takes a list as a parameter, prompts the user to enter a whole number n, and prints the element in position Index[n]. If the list is empty ([]) or n is not a valid index into the list, the function will not print anything. Be careful to do the correct thing with negative indices. You should assume that the user will enter a whole number when prompted, and the function will crash if the user does not enter an integer. The function should not change the list passed as a parameter. Hint: Just because this involves a list does not mean that you need a loop to solve the problem. Think carefully about the right construct to use here. The following shows the function template, and several examples runs of the function (you must show all the examples with these values in your submission): Template def printIndex(lst):     replace with your docstring       newList = lst # ________________________     elementNum =…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning