C++:
Write a program using Stacks-Array and Queue-Array data structure we did in class to check whether a given string is a palindrome. (50 points)
This is an exercise in Stacks and Queues. So you need to use both datastructures to test :
In the main you can test whether a string is a palindrome using the method
bool palindromeTest( string test) and should include “QueArr.h” and “StackArr.h”
QueArr.h
#include <iostream>
using namespace std;
template <class ItemType>
class QueArr
{
private:
int maxSize;
int front;
int rear;
ItemType * items;
public:
QueArr();
QueArr(int size);
~QueArr();
void makeEmpty();
bool isEmpty() const;
bool isFull() const;
void add(ItemType item);
void remove(ItemType& item);
void print() const;
};
template <class ItemType>
QueArr<ItemType>::QueArr()
{
maxSize = 100;
front = maxSize - 1;
rear = maxSize - 1;
items = new ItemType [maxSize];
}
template <class ItemType>
QueArr<ItemType>::QueArr( int size )
{
maxSize = size;
front = maxSize - 1;
rear = maxSize - 1;
items = new ItemType[maxSize];
}
template <class ItemType>
QueArr<ItemType>::~QueArr()
{
delete[] items;
}
template <class ItemType>
void QueArr<ItemType>::makeEmpty()
{
front = maxSize - 1;
rear = maxSize - 1;
}
template <class ItemType>
bool QueArr<ItemType>::isEmpty() const
{
return (rear == front);
}
template <class ItemType>
bool QueArr<ItemType>::isFull() const
{
return ((rear + 1) % maxSize == front);
}
template <class ItemType>
void QueArr<ItemType>::add(ItemType item)
{
if (isFull())
cout << "Queue is Full"
<< endl;
else
{
rear = (rear + 1) % maxSize;
items[rear] = item;
}
}
template <class ItemType>
void QueArr<ItemType>::remove(ItemType& item)
{
if (isEmpty())
cout << "Queue is empty"
<< endl;
else
{
front = (front + 1) %
maxSize;
item = items[front];
}
}
template <class ItemType>
void QueArr<ItemType>::print() const
{
if (isEmpty())
cout << "Que is empty"
<< endl;
else
{
//cout << front << ", "
<< length << endl;
int temp = front;
while(temp != rear)
{
temp = (temp +
1) % maxSize;
cout <<
items[temp] << " ";
}
cout << endl;
}
}
StackArr.h
#include <iostream>
using namespace std;
template <class ItemType>
class StackArr
{
public:
StackArr();
//Empty constructor
StackArr(int max); //Constructor which takes a
size
bool IsEmpty() const;
bool IsFull() const;
void Push(ItemType item);
void Pop();
ItemType Top() const;
void PrintStack();
private:
int top;
int maxStack;
ItemType* items;
int length;
};
template <class ItemType>
StackArr<ItemType>::StackArr()
{
maxStack = 100;
top = -1;
items = new ItemType[maxStack];
length = 0;
}
template <class ItemType>
StackArr<ItemType>::StackArr( int max)
{
maxStack = max;
top = -1;
items = new ItemType[maxStack];
length = 0;
}
template <class ItemType>
bool StackArr<ItemType>::IsEmpty() const
{
return (top == -1);
}
template <class ItemType>
bool StackArr<ItemType>::IsFull() const
{
return (top == maxStack - 1);
}
template <class ItemType>
void StackArr<ItemType>::Push(ItemType item)
{
if (IsFull())
{
cout << "The stack is full
and item cannot be pushed";
}
else
{
top++;
items[top] = item;
length++;
}
}
template <class ItemType>
void StackArr<ItemType>::Pop()
{
if(IsEmpty())
{
cout << "The stack is empty
and item cannot be popped";
}
else
{
top--;
length--;
}
}
template <class ItemType>
ItemType StackArr<ItemType>::Top() const
{
if (IsEmpty())
{
cout << "The stack is empty
and no item on top";
}
else
return items[top];
}
template <class ItemType>
void StackArr<ItemType>::PrintStack()
{
if (length == 0)
cout << "Stack is empty"
<< endl;
else
{
for (int i = 0; i < length;
i++)
cout <<
items[i] << ", ";
cout << endl;
}
}
In: Computer Science
Risk Register
Assignment Content
Tony and his project team identified some risks during the first month of the Recreation and Wellness Intranet Project. However, all they did was document the risks in a list. They never ranked the risks or developed any response strategies. Because the project has had several problems, such as key team members leaving the company, users being uncooperative, and team members not providing good status information, Tony decided to be more proactive in managing risks and want to address positive risks as well as negative risks.
Complete the following tasks:
In: Computer Science
Question 7 Use the definition of Ω to show that 20(?^3) + 5(n^2) ∈ Ω (?^3)
Big-O, Omega, Theta complexity of functions, Running time equations of iterative functions & recursive functions, Substitution method & Master theorem
Please answer within these topics.
In: Computer Science
Hexadecimal numbers are numbers in base 16. They use the following sixteen digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. They are widely used in computing, for example, to represent colors or network addresses of computers.
In: Computer Science
Why is it costly if an error was discovered in later phases of software development?
In: Computer Science
3) Convert 1.25 decimal to 32 bit floating point format. 4) Convert the following truth table to a digital circuit consisting of NOT, AND, and OR gates. ABC Out 000 1 001 1 010 0 011 0 100 1 101 0 110 1 111 0 5) Construct a tri-state buffer using transistors
10) What are the advantages of a large page size?
In: Computer Science
Compare and contrast the representation and use of primitive data types and built-in data structures such as C-strings and string objects?
In: Computer Science
Web Mining Assignments
Exercise 6.1.1 : Suppose there are 100 items, numbered 1 to 100, and also 100 baskets, also numbered 1 to 100. Item i is in basket b if and only if i divides b with no remainder. Thus, item 1 is in all the baskets, item 2 is in all fifty of the even-numbered baskets, and so on. Basket 12 consists of items {1, 2, 3, 4, 6, 12}, since these are all the integers that divide 12. Answer the following questions:
(a) If the support threshold is 5, which items are
frequent?
! (b) If the support threshold is 5, which pairs of items are
frequent?
! (c) What is the sum of the sizes of all the baskets?
PS: I know the answer of a) which are 1, 2, 3, 4 ... 18, 19, 20. But how to get the answers of b) and c) please show the steps and the explanation. Thank you.
In: Computer Science
Exp1:
import java.util.Scanner;
public class User_Authentication
{
public static void main(String args[])
{
String username, password;
Scanner s = new Scanner(System.in);
System.out.print("Enter username:");//username:user
username = s.nextLine();
System.out.print("Enter password:");//password:user
password = s.nextLine();
if(username.equals("Bisha") && password.equals("Computer"))
{
System.out.println("Authentication Successful");
}
else
{
System.out.println("Authentication Failed");
}
}
}
Exp3:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
static Scanner sc=new Scanner(System.in);
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
public static void main(String[] args) throws IOException {
// TODO code application logic here
System.out.print("Enter any String: ");
String str = br.readLine();
System.out.print("\nEnter the Key: ");
int key = sc.nextInt();
String encrypted = encrypt(str, key);
System.out.println("\nEncrypted String is: " +encrypted);
String decrypted = decrypt(encrypted, key);
System.out.println("\nDecrypted String is: "
+decrypted); System.out.println("\n");
}
public static String encrypt(String str, int key)
{ String encrypted = "";
for(int i = 0; i < str.length(); i++) {
int c = str.charAt(i);
if (Character.isUpperCase(c)) {
c = c + (key % 26);
if (c > 'Z')
c = c - 26;
}
else if (Character.isLowerCase(c)) {
c = c + (key % 26);
if (c > 'z')
c = c - 26;
}
encrypted += (char) c;
}
return encrypted;
}
public static String decrypt(String str, int key)
{ String decrypted = "";
for(int i = 0; i < str.length(); i++) {
int c = str.charAt(i);
if (Character.isUpperCase(c)) {
c = c - (key % 26);
if (c < 'A')
c = c + 26;
}
else if (Character.isLowerCase(c)) {
c = c - (key % 26);
if (c < 'a')
c = c + 26;
}
decrypted += (char) c;
}
return decrypted;
}
}
need your help regarding attached for all the questions
Answered it from your mind Do not copying the Answered Especially "D"
In: Computer Science
a. Create a SLL for N Data by using front insertion.
b. Display the status of SLL and count the number of nodes in it
c. Perform Insertion and Deletion at End of SLL
d. Perform Insertion at the third position.
e. Delete the element at the Front of SLL
f. Perform Deletion at second position of SLL
g. Display the content.
Linked List (SLL) of Student Data with the fields: USN, Name, Branch, Sem, PhNo
a. Create a SLL of N Students Data by using front insertion.
b. Display the status of SLL and count the number of nodes in it
c. Perform Insertion and Deletion at End of SLL
d. Perform Insertion and Deletion at Front of SLL
e. Display the content.
a. Create a DLL for N Data by using front insertion.
b. Perform Insertion and Deletion at End of DLL
d. Perform Insertion at the third position.
e. Delete the element in the Front of SLL
f. Perform Deletion at second position of SLL
g. Display the content.
In: Computer Science
Write a program that meets the following requirements:
Cat Class
- name
- breed
- number of legs
- year born
There should be NO main method in the Cat class.
CatTester Class
In: Computer Science
Q2.1 Write a Java program called Div that takes 2 (two) double command-line arguments as inputs, dividend and divisor (in that order) and performs a division operation. Your program either prints the quotient or an error if the divisor is zero. The divisor is the number you divide the dividend by.
public class Div
{
public static void main ( String[] args )
{
// WRITE YOUR CODE HERE
}
}
Q2.2
Write a Java program called IntCheck that examines the integer variable x, printing GT (greater than) if x is greater than 100, LT (less than) if x is less than 100 and EQ (equal) if x is 100.
public class IntCheck { public static void main ( String[] args ) { int x = Integer.parseInt(args[0]); // WRITE YOUR CODE HERE } }
In: Computer Science
Python Programming Problem:
If I have to separate lists, one contains a large string of paragraphs of words, and one contains just words, how can i iterate the words in my second list and compare it to my paragraph list to see how many times that word has occurred?
List1 = ['paragraph.......']
List2 = ['words', 'words', 'words'......]
these are just minimal examples
how do i approach this problem?
apprently numpy helps with processing time for something like this? cuz the lists could get quite big
In: Computer Science
Reflect on how the concepts and material presented in this Foundations of Research course can be used in your future academic endeavors. Include a specific example of a concept or assignment that you found most beneficial.
In: Computer Science
Please write code in c++ using iostream library.
Write a function bool cmpr(char * s1, int SIZE1, char * s2, int
SIZE2) that compares two strings.
Input
Input contains two strings. Each string is on a separate line.
example:
aqua
aqua
Output
Output YES if given two strings are the same or NO otherwise.
YES
In: Computer Science