C++ Question
Write a code for :-
public List Palindrome();
//Check whether a given singly linked list is palindrome or not.
Input:
a -> b-> NULL
a -> b -> a-> NULL
s -> a -> g -> a -> r-> NULL r -> a -> d -> a -> r-> NULL
Output:
not palindrome palindrome
not palindrome palindrome
Note:- Code should work on MS-Visual Studio 2017 and provide outputs with code
In: Computer Science
IMPLEMENT IN JAVA PLEASE I NEED THIS DONE ASAP
Question 1 (25pt) Dynamic Programming – Coin Change
Design algorithm for the coin change problem using dynamic programming approach. Given coin denominations by value: c1 < c2 < … < cn, and change amount of x, find out how to pay amount x to customer using fewest number of coins.
Your algorithm needs to work for ANY coin denomination c1 < c2 < … < cn, and ANY change amount of x. For example, given coin denominations 1, 5, 10, 25, x=78, the solution is {3 coins of 25 and 3 coins of 1, total 6 coins}.
NEED TO DO ALL 3 PARTS
• Present your algorithm in pseudo code.
• Trace your algorithm and show how it works on a small example, show the step-by-step process and the final result.
• Analyze the time complexity of the algorithm and present the result using order notation.
In: Computer Science
|
Hide Assignment Information |
|
| Instructions | |
|
In this assignment, you will be practicing the Java OOP skills we've learned this week in implementing a customized mutable Array class. Please read the following requirements carefully and then implement your own customized Array class: === 1) Basic (100' pts total) === Your Array class must provide the following features: --1.1) (20' pts) Two constructors. One takes the input of the initialized capacity (int) and create the underlying array with that capacity; the other takes no input and creates an array that can hold a single element by default (that is, init capacity == 1); --1.2) (20' pts) Getters and setters and basic methods we discussed during the class including: getCapacity(), getSize(), set(int index), get(int index), isEmpty(); --1.3) (20' pts) CRUD operations we discussed during the class including: add(int index), addLast(), addFirst(), remove(int index), removeLast(), removeFirst(), removeElement(int target), removeAll(int target); --1.4) (20' pts) Supports generic types; --1.5) (20' pts) Mutable, that is when add element exceeding its capacity, it can resize to accommodate the change. === 2) Bonus (20' pts total) === 2.1) (10' pts) Implement a (private or public) swap(int a, int b) method that swaps the two elements in the index a and b if a and b are both admissible; also a public reverse() method that reverses the order of stored elements in-place (means, no additional spaces are allocated). 2.2) (10' pts) A public void sort() method sorts the stored elements in ascending order inO(nlog(n)) time. [hint]: Quicksort or Merge sort |
|
In: Computer Science
Multidimensional Arrays
Design a C program which uses two two-dimensional arrays as
follows:
- an array which can store up to 50 student names where a name is
up to 25 characters long
- an array which can store marks for 5 courses for up to 50
students
The program should first obtain student names and their
corresponding marks for a requested number of students from the
user. Please note that the program should reject any number of
students that is requested by the user which is greater than 50.
The program will compute the average mark for each course and then
display all students and their marks, as well as the average mark
for each course.
A sample output produced by the program is shown below, if assumed
that the user entered marks for 4 students. Please note that the
computation of the average mark for each course should use type
casting.
Student PRG DGS MTH ECR GED
Ann Smart 93 85 87 83 90
Mike Lazy 65 57 61 58 68
Yo Yo 78 65 69 72 75
Ma Ma 84 79 83 81 83
AVERAGE 80.0 71.5 75.0 73.5 79.0
It is required to submit your source code file, i.e. Lab5.c file as
well as a file with your program's run screen captures.
In: Computer Science
Multidimensional Arrays
Design a C program which uses two two-dimensional arrays as
follows:
- an array which can store up to 50 student names where a name is
up to 25 characters long
- an array which can store marks for 5 courses for up to 50
students
The program should first obtain student names and their
corresponding marks for a requested number of students from the
user. Please note that the program should reject any number of
students that is requested by the user which is greater than 50.
The program will compute the average mark for each course and then
display all students and their marks, as well as the average mark
for each course.
A sample output produced by the program is shown below, if assumed
that the user entered marks for 4 students. Please note that the
computation of the average mark for each course should use type
casting.
Student PRG DGS MTH ECR GED
Ann Smart 93 85 87 83 90
Mike Lazy 65 57 61 58 68
Yo Yo 78 65 69 72 75
Ma Ma 84 79 83 81 83
AVERAGE 80.0 71.5 75.0 73.5 79.0
It is required to submit your source code file, i.e. Lab5.c file as
well as a file with your program's run screen captures.
In: Computer Science
Please complete it in C++
Part 1: Stack
The algorithm for checking is as follows:
At the end of the file, if the stack IS NOT EMPTY, output "The code is incorrect". Otherwise, output "The code is correct".
Use the provided files, testfile1.txt and testfile2.txt to test your program. The code file testfile1.txt is correct, while the code file testfile2.txt is incorrect.
Useful code:
|
#include <fstream> string readFile() { string tempString = ""; string filename;
cout << "Input file name: "; cin >> filename; ifstream inputFile(filename);
// Prompt user again if wrong filename received while (!inputFile.good()) { cout << "Wrong file name, input again please: "; cin >> filename; inputFile.open(filename); }
// Append all lines from the file into a long string while ((!inputFile.eof())) { string str; getline(inputFile, str); tempString += str; }
return tempString; } |
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "StackArr.h"
#include <string>
#include <iostream>
using namespace std;
StackArr::StackArr(int size) {
maxTop = size;
values = new char[size];
stackTop = -1;
}
StackArr::~StackArr() {
delete[] values;
}
bool StackArr::isEmpty() const {
return stackTop == -1;
}
bool StackArr::isFull() const {
return stackTop == maxTop;
}
void StackArr::push(const char& x) {
if (isFull())
cout << "Error! The stack is
full!" << endl;
else
values[++stackTop] = x;
}
char StackArr::pop() {
if (isEmpty()) {
cout << "Error! The stack is
empty!" << endl;
return -1;
}
else
return values[stackTop--];
}
char StackArr::top() const {
if (isEmpty()) {
cout << "Error! The stack is
empty!" << endl;
return -1;
}
else
return values[stackTop];
}
void StackArr::displayStack() const {
cout << "Top -->";
for (int i = stackTop; i >= 0; i--)
cout << "\t|\t" <<
values[i] << "\t|" << endl;
cout << "\t|---------------|" <<
endl;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "StackArr.h"
#include <string>
#include <iostream>
using namespace std;
StackArr::StackArr(int size)
maxTop = size;
values = new char[size];
stackTop = -1;
}
StackArr::~StackArr() {
delete[] values;
bool StackArr::isEmpty() const {
return stackTop == -1;
}
bool StackArr::isFull() const {
return stackTop == maxTop;
}
void StackArr::push(const char& x) {
if (isFull())
cout << "Error! The stack is
full!" << endl;
else
values[++stackTop] = x;
}
char StackArr::pop() {
if (isEmpty()) {
cout << "Error! The stack is
empty!" << endl;
return -1;
}
else
return values[stackTop--];
}
char StackArr::top() const {
if (isEmpty()) {
cout << "Error! The stack is
empty!" << endl;
return -1;
}
else
return values[stackTop];
}
void StackArr::displayStack() const {
cout << "Top -->";
for (int i = stackTop; i >= 0; i--)
cout << "\t|\t" <<
values[i] << "\t|" << endl;
cout << "\t|---------------|" <<
endl;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//StackArr.h
#ifndef STACKARR_H
#define STACKARR_H
class StackArr {
private:
int maxTop;
int stackTop;
char *values;
public:
StackArr(int);
~StackArr();
bool isEmpty() const;
bool isFull() const;
char top() const;
void push(const char& x);
char pop();
void displayStack() const;
};
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////StackArr.cpp
#include "StackArr.h"
#include <string>
#include <iostream>
using namespace std;
StackArr::StackArr(int size) {
maxTop = size;
values = new char[size];
stackTop = -1;
}
StackArr::~StackArr() {
delete[] values;
}
bool StackArr::isEmpty() const {
return stackTop == -1;
}
bool StackArr::isFull() const {
return stackTop == maxTop;
}
void StackArr::push(const char& x) {
if (isFull())
cout << "Error! The stack is
full!" << endl;
else
values[++stackTop] = x;
}
char StackArr::pop() {
if (isEmpty()) {
cout << "Error! The stack is
empty!" << endl;
return -1;
}
else
return values[stackTop--];
}
char StackArr::top() const {
if (isEmpty()) {
cout << "Error! The stack is
empty!" << endl;
return -1;
}
else
return values[stackTop];
}
void StackArr::displayStack() const {
cout << "Top -->";
for (int i = stackTop; i >= 0; i--)
cout << "\t|\t" <<
values[i] << "\t|" << endl;
cout << "\t|---------------|" << endl
<< endl;
}
In: Computer Science
Remove inline style to an external file
<!DOCTYPE html>
<html>
<head>
<title>PROBLEM</title>
</head>
<body>
<form>
<table style="color:white;background-color:blue;border:solid
black 7px;border-radius:25px;">
<tr><th colspan="2"
style="color:white;background-color:black;border:solid black
2px;outline:solid black 2px;">SQUARE
PROBLEM</th></tr>
<tr> <td><label>Enter
side:</label></td><td> <input type="text"
style="background-color:#DEDEE6;border:4px solid red;"/>
</td> </tr>
<tr>
<td><label>Area:</label></td><td>
<input type="text" readonly
style="background-color:#DEDEE6;border:4px solid yellow;"/>
</td> </tr>
<tr>
<td><label>Perimeter:</label></td>
<td> <input type="text" readonly
style="background-color:#DEDEE6;border:4px solid yellow;"/>
</td> </tr>
<tr>
<td colspan="2" >
<center>
<input type="button" value="Area"
style="color:white;background-color:black;border:1px solid
red;"/>
<input type="button" value="Perimeter"
style="color:white;background-color:black;border:1px solid
white;"/>
<input type="button" value="Both"
style="color:white;background-color:black;border:1px solid
red;"/>
<input type="button" value="Clear"
style="color:white;background-color:black;border:1px solid
white;"/>
</center>
</td>
</tr>
</table>
</form>
</body>
</html>
In: Computer Science
The use of list or any other data type not allowed only string and string methods .Hint: Depending on how you plan to solve this problem, accumulator variable initialized as an empty string may help in this question. Write a function called weaveop, that takes a single string parameter (s) and returns a string. This function considers every pair of consecutive characters in s. It returns a string with the letters o and p inserted between every pair of consecutive characters of s, as follows. If the first character in the pair is uppercase, it inserts an uppercase O. If however, it is lowercase, it inserts the lowercase o. If the second character is uppercase, it inserts an uppercase P. If however, it is lowercase, it inserts the lowercase p. If at least one of the character is not a letter in the alphabet, it does not insert anything between that pair. Finally, if s has one or less characters, the function returns the same string as s. Do dir(str) and check out methods isalpha (by typing help(str.isalpha) in Python shell), and isupper
>>> weaveop("aa") 'aopa'
>>> weaveop("aB") 'aoPB'
>>> weaveop("ooo") 'oopoopo'
>>> weaveop("ax1") 'aopx1'
>>> weaveop("abcdef22") 'aopbopcopdopeopf22'
>>> weaveop("abcdef22x") 'aopbopcopdopeopf22x'
>>> weaveop("aBCdef22x") 'aoPBOPCOpdopeopf22x'
>>> weaveop("x") 'x'
>>> weaveop("123456") '123456'
In: Computer Science
Computer dynamics is a microcomputer software development company that has a 300-computer network. The company is located in three adjacent five-story buildings in an office park with about 100 computers in each building. The LANs in each building are similar, but one building has the data center in the second floor. There are no other office locations. Please refer to the network architecture components in Figure 6-1 of the textbook, and identify the key network architecture components in the design of the enterprise network. Refer to Chapter 6 and discuss how you would go about designing the physical network. You may assume that the campus does not need WAN connectivity.
Dear All,
This week; you are going to Design a "Real World" scenario Network as specified above.
Please start with a blue print design using "Visio" software Try first to think about the "Hardware-Devices" such as Wired Switches, Routers, Cables and Wireless Access Points, Wireless Repeaters (Extenders). See and estimate the number of users for your network, and put no more than 15 users/Access points for the Wireless connection, and select the wired switches to have X number of ports so that the over-ll wired users would be efficiently covered.
In: Computer Science
void append(Node list1, Node list2)
If the list1 is {22, 33, 44, 55} and list2 is {66, 77, 88, 99} then append(list1, list2) will change list1 to {22, 33, 44, 55, 66, 77, 88, 99}. (5 Marks: 1mark for each correct step)
int sum(Node list)
If the list is {25, 45, 65, 85} then sum(list) will return 220. (5 Marks: 1mark for each correct step)
L.add(50);
L.add(60);
L.addFirst(10);
L.addLast(100);
L.set(1, 20);
L.remove(1);
L.remove(2);
L.removeFirst();
L.removeLast(); (10 Marks: 1 mark for each correct answer)
L.addFirst(10);
Array and Linked List
In: Computer Science
Please complete it in C++
Part 2: Queue
The following shows a number of program's sample input / output sessions.
Input a string: aibohphobia
aibohphobia is a palindrome
Input a string: level
level is a palindrome
Input a string: desmond
desmond is not a palindrome
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////StackArr.h
#ifndef STACKARR_H
#define STACKARR_H
class StackArr {
private:
int maxTop;
int stackTop;
char *values;
public:
StackArr(int);
~StackArr();
bool isEmpty() const;
bool isFull() const;
char top() const;
void push(const char& x);
char pop();
void displayStack() const;
};
#endif
#pragma once
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////StackArr.cpp
#include "StackArr.h"
#include <string>
#include <iostream>
using namespace std;
StackArr::StackArr(int size) {
maxTop = size;
values = new char[size];
stackTop = -1;
}
StackArr::~StackArr() {
delete[] values;
}
bool StackArr::isEmpty() const {
return stackTop == -1;
}
bool StackArr::isFull() const {
return stackTop == maxTop;
}
void StackArr::push(const char& x) {
if (isFull())
cout << "Error! The stack is
full!" << endl;
else
values[++stackTop] = x;
}
char StackArr::pop() {
if (isEmpty()) {
cout << "Error! The stack is
empty!" << endl;
return -1;
}
else
return values[stackTop--];
}
char StackArr::top() const {
if (isEmpty()) {
cout << "Error! The stack is
empty!" << endl;
return -1;
}
else
return values[stackTop];
}
void StackArr::displayStack() const {
cout << "Top -->";
for (int i = stackTop; i >= 0; i--)
cout << "\t|\t" <<
values[i] << "\t|" << endl;
cout << "\t|---------------|" << endl
<< endl;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////QueueArr.h
#ifndef QUEUEARR_H
#define QUEUEARR_H
class QueueArr {
private:
int front;
int back;
int counter;
int maxSize;
char* values;
public:
QueueArr(int);
~QueueArr();
bool isEmpty() const;
bool isFull() const;
bool enqueue(char x);
char dequeue();
void displayQueue() const;
};
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////QueueArr.cpp
#include "QueueArr.h"
#include <string>
#include <iostream>
using namespace std;
QueueArr::QueueArr(int size) {
values = new char[size];
maxSize = size;
front = 0;
back = -1;
counter = 0;
}
QueueArr::~QueueArr() {
delete[] values;
}
bool QueueArr::isEmpty() const {
if (counter)
return false;
else
return true;
}
bool QueueArr::isFull() const {
if (counter < maxSize)
return false;
else
return true;
}
bool QueueArr::enqueue(char x) {
if (isFull()) {
cout << "Error! The queue is
full." << endl;
return false;
}
else {
back = (back + 1) % maxSize;
values[back] = x;
counter++;
return true;
}
}
char QueueArr::dequeue() {
char x = -1;
if (isEmpty()) {
cout << "Error! The queue is
empty." << endl;
return -1;
}
else {
x = values[front];
front = (front + 1) %
maxSize;
counter--;
return x;
}
}
void QueueArr::displayQueue() const {
cout << "Front -->";
for (int i = 0; i < counter; i++) {
if (i == 0)
cout <<
"\t";
else
cout <<
"\t\t";
cout << values[(front + i) %
maxSize];
if (i != counter - 1)
cout <<
endl;
else
cout <<
"\t<--Back" << endl;
}
cout << endl;
}
In: Computer Science
C++ Question
Create two circular linked lists and find their maximum numbers. Merge the two circular linked lists such that the maximum number of 2nd circular linked list immediately follows the maximum number of the 1st circular linked list.
Input:
12 -> 28 -> 18 -> 25 -> 19-> NULL
5 -> 24 -> 12 -> 6 -> 15-> NULL
Output:
28 -> 24-> 25 -> 15 -> 19 -> 15->5-> 18 -> 25 -> 19->NULL
Note:- Code should work on MS-Visual studio 2017 and provide output along with code
In: Computer Science
Apply following to header and footer sections of page:
center text
background color rgb(254,198,179)
padding should be 20px
In: Computer Science
Describe/define/explain
a. The relationship between Java's Iterable and Iterator
interfaces
b. An inner class
c. An anonymous inner class
d. The functionality of an Iterator remove method
In: Computer Science
Assignment details
In: Computer Science