Questions
1. Create the binary tree that has postorder traversal of { b d a h g...

1. Create the binary tree that has postorder traversal of { b d a h g c f,} and has the inorder traversal of {b i a d f g h c}

2. Create the binary tree that has the preorder traversal of {10, 20, 40, 50, 80, 60, 70, 90} and the inorder traversal of { 40, 50, 20, 10, 80, 70, 90, 60}

In: Computer Science

Discuss how social media was used in the 2016 U.S. Presidential Election in terms of communicating...

Discuss how social media was used in the 2016 U.S. Presidential Election in terms of communicating with voters, fundraising, and campaign organizing. Discuss how databases of political information can be used to help voters make decisions on candidates and issues. Support your discussion with reliable sources.

In: Computer Science

"What is Social Media" and "How is social media influencing web applications and development?" Include in...

"What is Social Media" and "How is social media influencing web applications and development?" Include in your discussion three of your favorite sites including what it is that you like or dislike about them. Your sites can be within the realm of social media or from sites that are somehow integrated into social media.

In: Computer Science

Using Java. The following is a constructor I need to implement but I am not sure...

Using Java. The following is a constructor I need to implement but I am not sure how. It also must pass the Junit test. Please give reasoning while answering.

public class LZWDictionary {

// FIELDS

// map (for ease of checking existence of entries)

// list (ease of recall of an entry)

LinkedHashMap<String, Integer> map;

List<String> list;

/**

* Initializes the LZWDictionary to have an initial set of entries taken from

* the set of unique characters in a provided string

*

*

*

* Unique characters are added to a map as they are encountered in the provided

* input string, with an increasing index value (beginning at index 0). At the same

* time, the characters are added to a list. The indices associated with each

* dictionary entry in the map thus relate to their index (position) in the list

*

*

*

*

* @param characters a string of initial characters that may include duplicates

*

* @throws an IllegalArgumentException if the characters string is empty

*

*/

public LZWDictionary(String characters) {

// NOTE: Complete the accessors getMap() and getList() first before running

// your tester on this ctor

}

Must pass this Junit Test

In: Computer Science

This task is solved in Python 3. Develop a program that can, among other things, manage...

This task is solved in Python 3.

Develop a program that can, among other things, manage your courses and course results.

It must also be able to calculate the average grade, for all grades or for a selection of grades

limited to a certain subject area and / or course level (100, 200 or 300 level).

NB! All courses are worth the same amount of credits.

The program should have two global collections

  • Courses is a list that contains the courses you have taken or plan to take.

All courses belong to a subject area and have a course code that starts with at least three letters and always ends with three digits, of which the first digit is 1, 2 or 3 which indicates the level of the course.

  • Grades are a list of course results. For example

Grades = {"INFO100": "C", "INFO104": "B", "ECON100": "B",…}

(All courses registered in Grades must be found in Courses, but not necessarily vice versa.)

The program should let the user select action from a menu and continue until the user chooses to exit.

The purpose of the program is for you to be able to calculate your grade points, in total and for granted subject areas and / or levels. In addition, you should be able to add new courses and set / change grades temporarily so you can experiment with how improved and upcoming results will give an effect on the grade point average.

Try to make the program robust for errors on the part of the user, such as entering a rating in form of a number, or a letter outside A-F.

On the next page you will find a guiding example of what the dialogue can look like:

>>> start ()

--------------------

1 Course list

2 Add course

3 Grade

4 Grade point average

5 Exit

--------------------

Choose action (0 for menu)> 1

Choose course and / or course level (<enter> for all)

- Course:

- Level:

INFO100 C

INFO104 B

INFO125 B

INFO132 A

INFO180

INFO216 A

INFO282 C

INFO284

ECON100 C

ECON110 C

ECON218

GE0100

GEO113 D

GEO124 D

Choose action (0 for menu)> 2

New course: ECON221

Choose action (0 for menu)> 1

Choose course and / or course level (<enter> for all)

- Course: Economics

- Level: 200

ECON218

ECON221

Choose action (0 for menu)> 3

Course: INFO284

Grade (<enter> to delete): B

Choose action (0 for menu)> 4

Choose course and / or course level (<enter> for all)

- Course: Information science

- Level: 100

Average: B

Choose action (0 for menu)> 4

Choose course and / or course level (<enter> for all)

- Course:

- Level:

Average: C

Choose action (0 for menu)> 0

--------------------

1 Course list

2 Add course

3 Grades

4 Grade point average

5 Exit

--------------------

Choose action (0 for menu)> 3

Course: GEO124

Grade (<enter> to delete): A

Choose action (0 for menu)> 4

Choose course and / or course level (<enter> for all)

- Course:

- Level:

Grade point average: B

Select action (0 for menu)> 5

Thanks for now

>>>

In: Computer Science

Write a paragraph about the VIM editor.

Write a paragraph about the VIM editor.

In: Computer Science

Your task is to determine the least common multiple of two integers. You will need to...

Your task is to determine the least common multiple of two integers.

You will need to use the Euclidean algorithm for GCD to prevent going above the time limit.

input specification

The first line will contain a single integer NN (1<N<100001

answer must be in c++ language

The following NN lines will each contain a 2 integers aa and bb (1<a,b<1000000001

In: Computer Science

In a game of Tic Tac Toe, two players take turns making an available cell in...

In a game of Tic Tac Toe, two players take turns making an available cell in a 3 x 3 grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A stalemate occurs when all the cells on the grid have been filled with tokens and neither player has achieved a win.

Write a program that emulates a Tic Tac Toe game.

When you are done, a typical session will look like this:

 Welcome to tic-tac-toe.
 Enter coordinates for your move following the X and O prompts.
   1 2 3
A   | | 
   -----
B   | | 
   -----
C   | |

X:A2
   1 2 3
A   |X| 
   -----
B   | | 
   -----
C   | |

O:B3
   1 2 3
A   |X| 
   -----
B   | |O
   -----
C   | |

And so on. Illegal moves will prompt the user again for a new move. A win or a stalemate will be announced, mentioning the winning side if any. The program will terminate whenever a single game is complete.

This file has the general framework of the TicTacToe class. An object of this class will represent a tic-tac-toe "board". The board will be represented internally by a two dimensional array of characters (3 x 3), and by a character indicating who's turn it is ('X' or 'O'). These are stored in the class instance variables as follows.

private char[][] board;
private char player; // 'X' or 'O'

You will need to define the following methods:

1. A constructor:

public TicTacToe()

to create an empty board, with initial value of a space (' ')

2. play method

public play(String position)

if position represents a valid move (e.g., A1, B3), add the current player's symbol to the board and return true. Otherwise, return false.

3. switchTurn method

public void switchTurn()

switches the current player from X to O, or vice versa.

4. won method

public boolean won()

Returns true if the current player has filled three in a row, column or either diagonal. Otherwise, return false.

5. stalemate method

public boolean stalemate()

Returns true if there are no places left to move;

6. printBoard method

 public void printBoard()

prints the current board

7. Use the following test code in your main method to create a TicTacToe object and print it using the printBoard method given, so as to test your code. Your printBoard method should produce the first board in the example above.

public static void main(String[] args) {

       Scanner in = new Scanner(System.in);
       TicTacToe game = new TicTacToe();
       System.out.println("Welcome to Tic-tac-toe");
       System.out.println("Enter coordinates for your move following the X and O prompts");
       
       while(!game.stalemate()) 
       {
              game.printBoard();
              System.out.print(game.getPlayer() + ":");

              //Loop while the method play does not return true when given their move.
              //Body of loop should ask for a different move
              while(!game.play(in.next()))
              {
                    System.out.println("Illegal move. Enter your move.");
                    System.out.print(game.getPlayer() + ":");
               }
              //If the game is won, call break;
              if(game.won())
                  break;

              game.printBoard();
              //Switch the turn
              game.switchTurn();

        }
        game.printBoard();
        if(game.won())
        {
             System.out.println("Player "+game.getPlayer()+" Wins!!!!");
        } 
        else 
        {
             System.out.println("Stalemate");
        }
}

In: Computer Science

In a game of Tic Tac Toe, two players take turns making an available cell in...

In a game of Tic Tac Toe, two players take turns making an available cell in a 3 x 3 grid with their respective tokens (either X or O). When one player has placed three tokens in a horizontal, vertical, or diagonal row on the grid, the game is over and that player has won. A stalemate occurs when all the cells on the grid have been filled with tokens and neither player has achieved a win.

Write a program that emulates a Tic Tac Toe game.

When you are done, a typical session will look like this:

 Welcome to tic-tac-toe.
 Enter coordinates for your move following the X and O prompts.
   1 2 3
A   | | 
   -----
B   | | 
   -----
C   | |

X:A2
   1 2 3
A   |X| 
   -----
B   | | 
   -----
C   | |

O:B3
   1 2 3
A   |X| 
   -----
B   | |O
   -----
C   | |

And so on. Illegal moves will prompt the user again for a new move. A win or a stalemate will be announced, mentioning the winning side if any. The program will terminate whenever a single game is complete.

This file has the general framework of the TicTacToe class. An object of this class will represent a tic-tac-toe "board". The board will be represented internally by a two dimensional array of characters (3 x 3), and by a character indicating who's turn it is ('X' or 'O'). These are stored in the class instance variables as follows.

private char[][] board;
private char player; // 'X' or 'O'

You will need to define the following methods:

1. A constructor:

public TicTacToe()

to create an empty board, with initial value of a space (' ')

2. play method

public play(String position)

if position represents a valid move (e.g., A1, B3), add the current player's symbol to the board and return true. Otherwise, return false.

3. switchTurn method

public void switchTurn()

switches the current player from X to O, or vice versa.

4. won method

public boolean won()

Returns true if the current player has filled three in a row, column or either diagonal. Otherwise, return false.

5. stalemate method

public boolean stalemate()

Returns true if there are no places left to move;

6. printBoard method

 public void printBoard()

prints the current board

7. Use the following test code in your main method to create a TicTacToe object and print it using the printBoard method given, so as to test your code. Your printBoard method should produce the first board in the example above.

public static void main(String[] args) {

       Scanner in = new Scanner(System.in);
       TicTacToe game = new TicTacToe();
       System.out.println("Welcome to Tic-tac-toe");
       System.out.println("Enter coordinates for your move following the X and O prompts");
       
       while(!game.stalemate()) 
       {
              game.printBoard();
              System.out.print(game.getPlayer() + ":");

              //Loop while the method play does not return true when given their move.
              //Body of loop should ask for a different move
              while(!game.play(in.next()))
              {
                    System.out.println("Illegal move. Enter your move.");
                    System.out.print(game.getPlayer() + ":");
               }
              //If the game is won, call break;
              if(game.won())
                  break;

              game.printBoard();
              //Switch the turn
              game.switchTurn();

        }
        game.printBoard();
        if(game.won())
        {
             System.out.println("Player "+game.getPlayer()+" Wins!!!!");
        } 
        else 
        {
             System.out.println("Stalemate");
        }
}

In: Computer Science

In C++, 
 Define a structure Triangle that contains three Point members. Write a function that computes...

In C++, 
 Define a structure Triangle that contains three Point members. Write a function that computes the perimeter() of a Triangle. Write a program that reads the coordinates of the points, calls your function, and displays the result.

C++

In: Computer Science

Draw the class diagram of University; University (name and location etc) is maintaining the student affairs,...

Draw the class diagram of University; University (name and location etc) is maintaining the student affairs, faculty or non-faculty record, student record, hostel management, route management etc. University has a chancellor and different departments. Faculty and non-faculty members are the part of each department. Minimum 2 or 3 attributes and operations of each class. Show the cardinality or multiplicity constraints as well.

In: Computer Science

Suppose there are three users: DBA, user1, user2, user3. Please specify whether user1, user2, user3 have...

Suppose there are three users: DBA, user1, user2, user3. Please specify whether user1, user2, user3 have update privilege on checking and saving table after execution of the following SQL statements.


DBA:
Grant update on checking to user1 with grant option;
Grant update on checking to user2 with grant option;
Grant update on saving to public;
Grant update on saving to user2 with grant option;
User1:
Grant update on checking to user3;
User 2:
Grant update on checking to user3;
Grant update on saving to user3;
DBA:
Revoke update on checking from user1;
Revoke update on saving from public;

In: Computer Science

Solve this question in C++ language. DO NOT use loops. Use recursive function. Keep the program...

Solve this question in C++ language. DO NOT use loops. Use recursive function. Keep the program simple.

Q (5) Suppose you have been given the task to design a text editor which will take any multiline text from user and then display the statistics like total number of characters i.e., characters_count (excluding the white space and punctuations), words_count, and redundant_words_count. Create a structure named Text_Editor having four type members namely inserted_text (of type string), characters_count (of type unsigned int), words_count (of type unsigned int), and redundant_words_count (of type unsigned int). The structure should also have member functions namely Insert_Text( ) for obtaining the multiline text from user and assigning to input_text member-variable. End of text insertion should be specified by ‘#’ character. Moreover, there should be a separate member-function of the created structure named Count_Ch( ), Count_Words( ), and Count_Redundant_Words( ) that should process the input text in order to calculate and print the relevant statistics. All these different tasks are to be implemented using recursion technique.                                (30 Points)

In: Computer Science

Below are six ciphertexts of the same message encrypted using the following four classical ciphers available...

Below are six ciphertexts of the same message encrypted using the following four classical ciphers available in CrypTool: Caesar (shift), Substitution, Vigenere and Permutation.

Do your best to match ciphertexts with a cipher that could have been used to obtain the given ciphertext. If you are uncertain, you can list several ciphers per each ciphertext. Justify your answer. Find the plaintext, by breaking the Caesar (shift) cipher, and then find the keys for at least 3 ciphers used to encrypt the now known plaintext. All attacks must be documented. Brute-force attacks do not count.

Ciphertext 1

TFPEGO ZEKUUFJZ CZ NJNCSGZWV LWVJVH FWVL HDTD ISK QSRNYR BQJPJ

SZRPBV ML LVEIKLYVUBX WNLLQC SPJL SITU AAY EXIR TFPEGO ZEKUUFJZ

CZ NJNCSGZWR RACWHTQ HJCV CJRXSL JPIJAK NYR TG FXX CZRPBV ML

LVEIKLYVMFTIG PJCV XIPS KHQKG TS WKGWFUGKO NCQWZDTS TB TGTUAP

UBX YLRBPYSK HJCV XIPB LXQYAV WMCU NVL EFLPW VJNCSQ HB ZEKUUFJZ

CXS RVGSCGBQY HJCV AWIG UURJ AIEQ

Ciphertext 2

GSVGXK JOYOYMOJ LB NBJEOLLRO LRCTEK LRGL YGHO XBP KGHMPL TOQOJ

NBJEOL LB JOYOYMOJ LRO LRCTEK LRGL YGHO XBP ESGHGSVGXK JOYOYMOJ

LB NBJEOLLRO NJCOTHK LRGL FJBQOH PTLJPOMPL HB TBLNBJEOL LB

JOYOYMOJLRBKO LRGL RGQO KLPUA MX XBPGSVGXK JOYOYMOJ LB NBJEOL

LRO LJBPMSOK LRGL RGQO FGKKOH GVGXMPL TOQOJ NBJEOL LB JOYOYMOJ

LRO MSOKKCTEK LRGL UBYO OGUR HGX

Ciphertext 3

DOZDBVUHPHPEHU WR IRUJHWWKH WKLQJV WKDW PDGH BRX VDGEXW QHYHU

IRUJHW WR UHPHPEHUWKH WKLQJV WKDW PDGH BRX JODG DOZDBV UHPHPEHU

WR IRUJHWWKH IULHQGV WKDW SURYHG XQWUXHEXW GR QRW IRUJHW WR

UHPHPEHUWKRVH WKDW KDYH VWXFN EB BRXDOZDBV UHPHPEHU WR IRUJHW

WKH WURXEOHV WKDW KDYH SDVVHG DZDBEXW QHYHU IRUJHW WR UHPHPEHU

WKH EOHVVLQJV WKDW FRPH HDFK GDB

Ciphertext 4

AMESOV OHALEOIR EO ETUWETSAU GBSOWE THSR ETMD EGN VUGBAK YTEHS

NTRNEA RH AAFMHAAMEDE TEETBS OTAE ETTG EEG GYETTHGRFR PUFMETLB TE

PBRMSCYMR NENTRTU SOFT RTESSA MELEYOEET AL BTT UERETA MR

EOBRMHCARHTST EEIM SOTM BRMNE WE TTUOTTAYE OOHAERET CR FHAUGBGYA

RHHNNOHV OMRU AWRE BHHYTE TDOEIDL BTSDD TRHYRF RT DVOHSAEOIDT

EESOYTEAT OROE UEGB VAFM LAD

Ciphertext 5

ANWDCE ZEMGMEID BO FQRJIFBHE VHLRSA THCT PEPM YOW SDHNCT NGVHV

RWRGGT WS DMMEOBHVFPE TJIQKE BHAV MDHQ GOU ILDHMTWAAS UIYMMBGR WS

RWRGGTWLQ NRIGNGW FPAT RRRZQL UNVRXINCT DQ NRX RWRGGT WSDMMEOBHV

FPOSG TKEF PAVG SWYOS BY AOXEXEAYU RHQQUBET TR JAZGEVTKI FZOUDLHW

FPAT JAYI BISSGD DAMGBUV NHZQZ FOTGHX FW REOEPFQZTHG BOIEAINIS

WLMB COOE HEOP DAA

Ciphertext 6

VHIGCYI NKNBCNIVY DBICPKEKPIAPE FCHAPTVGVP FAYRYOHCQVE

NTNIDBICPKEKY FNKNKKFEYPIAPEF CHAPTVG VPFAYWCHVHO HZTAYS NKNKKFE

YBDYFKI KEAPNRIENFS HAPTVSEYOFPZR YEXRCQOPV FYVDBIC PKEK YFNK NKK

FEY DAPRAP TVAGTN PYRUMCTU AYWYHZTAY SNKNKKFEYB DYFKIKEAPP

KFYQCPNPY AGAPTOP TYHUPFPG ITACQVENT NIDBICPK EKYFNKNK KFEYPIMD

RPUPEFC HAPTVB YKNEPY GPSTA

In: Computer Science

Define and implement a class named Coach, which represents a special kind of person. It is...

Define and implement a class named Coach, which represents a special kind of person. It is to be defined by inheriting from the Person class. The Coach class has the following constructor:

Coach(string n, int sl) // creates a person with name n, whose occupation

// is “coach” and service length is sl

The class must have a private static attribute

static int nextID ;

which is the unique personID of the next Coach object to be created. This is incremented by 1 each time a new Coach object is created. This must be initialized to the value of 0 in the Coach.cpp file, the first coach has personID equal to 0.

Redefine the get_salary function inherited by Coach from Person so that it returns either the value of salary if the service length is less than 15 or three times the value of salary otherwise.

So we can check that your code compiles implement a program with a main method that declares a Coach object in a file called main-2-1.cpp.

2-2. Define and implement a class named Player, which represents a special kind of person. It is to be defined by inheriting from the Person class. The Player class has the following constructor and behaviour:

Player(string n, int sl, int *list, int m)

/* creates a person with name n, whose occupation is

“player” and service length is sl;

list records the time that a player spent in the

field in each game, the integers are distinct and

sorted in ascending order; m is the number of games

*/

int searchGame(int x)   

/* searches for a particular time x in the array of times;

returns either the index of x in the array if x exists or -1 otherwise;

you may use your favourite sorting algorithm

*/

The class must have a private static attribute

static int nextID ;

which is the unique personID of the next Player object to be created. This is incremented by 1 each time a new Player object is created. This must be initialized to the value of 1000 in the Player.cpp file, the first player has personID equal to 1000.

Redefine get_salary function inherited by Player from Person so that it returns either the value of salary if service length is less than 20 or three times the value of salary otherwise.

Function searchGame should look for a particular time x in the array of times. If x exists, it returns the array index of x in the array or it returns -1 otherwise.

So we can check that your code compiles implement a program with a main method that declares a Player object in a file called main-2-2.cpp.

code:

#ifndef PERSON_H

#define PERSON_H

#include <iostream>

using namespace std;

class Person{

protected:

string name; // the name of a person

string occupation; // the occupation of a person

int salary; // the salary of a person; takes only non-negative values

int serviceLength; // the service length of a person

int personID; // the unique ID of a person

public:

Person(string n, string o, int sl);

Person();

// for name

void set_name(string input);

string get_name();

// for occupation

void set_occupation(string input);

string get_occupation();

// for salary

void set_salary(int input);

virtual int get_salary();

// for serviceLength

int get_serviceLength();

// for personID

int get_personID();

~Person();

};

#endif

#include "Person.h"

#include <iostream>

using namespace std;

Person::Person(){

}

Person::Person(string n, string o, int sl){

name = n;

occupation = o;

serviceLength = sl;

salary = 1;

}

void Person::set_name(string input){

name = input;

}

string Person::get_name(){

return name;

}

void Person::set_occupation(string input){

occupation = input;

}

string Person::get_occupation(){

return occupation;

}

void Person::set_salary(int input){

if (input >= 0){

salary = input;

}

}

int Person::get_salary()

{

   return salary;

}

int Person::get_serviceLength(){

return serviceLength;

}

int Person::get_personID(){

return personID;

}

Person::~Person(){

}

In: Computer Science