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
True False
|
The enqueue and dequeue operations in a priority queue take O(lg n) time, while linked list and array implementations take O(1) time. |
||
|
A binary heap is a (nearly) complete binary tree. |
||
|
Heaps usually use a linked node structure for implementation. |
||
|
When implementing heaps as arrays, you can leave a blank space at the front. If you do, the parent of a node at index i can be found at index floor(i/2). |
||
|
When implementing heaps as arrays, if you don't leave a space at the front, you can find the children of the node at index i at 2i and 2i+1. |
||
|
The heap order property states that each node must contain a value greater than its left child and less than its right child. |
||
|
Insertion in a heap is done by adding at the end of the array and "percolating up". |
||
|
The average case for insertion in a heap is O(lg n). The worst case is O(n). |
||
|
Deletion in a heap requires removing the root item and shifting all other items over one space. |
||
|
Building a heap by adding values one at a time is an O(n) operation. Building a heap "all at once" with the heapify() method (called buildHeap() in the textbook) is O(n lg n). |
In: Computer Science
I need to implement a code in python to guess a random number. The number must be an integer between 1 and 50 inclusive, using the module random function randint. The user will have four options to guess the number. For each one of the failed attempts, the program it should let the user know whether is with a lower or higher number and how many tries they have left. If the user guess the number, the program must congratulate the user and tell him how much he won. If you are a user, hit on the 1st attempt He wins first $ 100, on the second $ 75, on the third $ 50, on the fourth $ 25. If the user misses all four opportunities, the program must inform the user that he owes money $ 60 and what was the number that the computer generates randomly.
In: Computer Science
Explain the diagram of Computer System which includes (Hardware, OS, application program and users).
In: Computer Science
The five major activities of an operating system in regard to process management are?
In: Computer Science
In: Computer Science
def main():
phrase = input('Enter a phrase: ') # take a phrase from user
acronym = '' # initialize empty acronym
for word in phrase.split(): # for each word in phrase
acronym += word[0].upper() # add uppercase version of first letter
to acronym
print('Acronym for ' + phrase + ' is ' + acronym) # print
results
main()
The program should then open the input file, treat whatever is on each line as a phrase and make its acronym using the function you wrote. It should print the acronyms, one per line to the output file. Assume that the input file will be already present in your default Python folder. The output file will be expected to get saved to the same folder. See below for an example input file input.txt and its corresponding output file output.txt that the program should generate.
Input: personal computer
Output:PC
In: Computer Science