Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.


An input string is valid if:


Open brackets must be closed by the same type of brackets.

Open brackets must be closed in the correct order.


Example 1:


Input: s = "()"

Output: true


Example 2:


Input: s = "()[]{}"

Output: true


Example 3:


Input: s = "(]"

Output: false


Example 4:


Input: s = "([)]"

Output: false


Example 5:


Input: s = "{[]}"

Output: true


*Your program output should follow the example in the instruction.


* The program should print the input parentheses and the output (true/false).                                                                     



*Parentheses.txt : ((()))


Please Follow this Program to Solve the Parentheses:



#include <stdio.h>

#include <string.h>


#define mx 1000000 //max size of 10^6


int str_sz;

char str[mx];


int stk_sz;

char stack[mx];


int checker() {

  stk_sz = 0;

  for (int i = 0; i < str_sz; i++) {

    if (str[i] == '(' || str[i] == '{' || str[i] == '[') { //if there is an opening bracket

      //push it on the stack

      stack[stk_sz] = str[i];

      stk_sz++;

    } else {

      if (stk_sz == 0) return 0; //if stack is empty, return 0


      switch (str[i]) {

      case ')':

        if (stack[stk_sz - 1] != '(') return 0;

        stk_sz--;

        break;


      case '}':

        if (stack[stk_sz - 1] != '{') return 0;

        stk_sz--;

        break;


      case ']':

        if (stack[stk_sz - 1] != '[') return 0;

        stk_sz--;

        break;

      }

    }

  }


  if (stk_sz > 0) return 0; //if stack is not empty, return 0

  return 1;

}


int main() {

  scanf("%s", str);

  str_sz = strlen(str);


  if (str_sz == 0) {

    puts("String is empty");

    return 0;

  }


  if (checker()) puts("Balanced");

  else puts("Not balanced");

}




You are required to complete this Parentheses program template I provide and use the stack to solve the problem. Please test the program.



#include <stdio.h>

#include <stdlib.h>


// This is where the parentheses are stored in memory

char buffer[1024];

char stack_pop();

void stack_push(char ch);

int stack_size();



int main(){

FILE *fp;

  // The parentheses sequences is in the parentheses.txt file.

  fp=fopen("parentheses.txt","r");

  if(fp==NULL){

  printf("The input file does not exist.\n");

  exit(-1);

  }

  // Read the parenthese sequences into buffer array.

  fgets(buffer,1024,fp);

  //printf("%s",buffer);

}


// The pop operation in the stack. To be done.

char stack_pop(){

return ')';

}



// The push operation in the stack. To be done.

void stack_push(char ch){

}



// The number of elements in the stack. To be done.

int stack_size(){

return 0;

}




Fill in the blank in the following program that draws a figure resembling the letter 'Z' with sides (50, 100, 50) and the angle between them to be 60 degrees.


Remember that the turtle starts at the center of the canvas and facing right.

left(180); forward(50); right(B1); forward(B2); left(B3); forward(50);

What is B1?



What is B2?



What is B3?



Fill in the blanks to complete the code that prints the string:

“bccbccbccaaaaaaaaaabccbccbccaaaaaaaaaa”


repeat(B1){

repeat(B2){

cout<<"b";

repeat(B3){

cout<<"c";

}

}

repeat(B4){

cout<<"a";

repeat(2){

cout<<"a";

}

}

}

What is B1?



What is B2?



What is B3?



What is B4?



Fill in the blanks in the following program so that it draws the given picture. Each

figure is a rhombus with side 100 and interior angles (60, 120, 60, 120). The distance

between 2 adjacent rhombuses is 20 (between their closest vertices).


repeat(2){

repeat(2){

B1;

left(B3);

B1;

left(120);

}

right(120);

penUp();

B2;

penDown();

repeat(2){

B1;

left(120);

B1;

left(B3);

}

right(B3);

penUp();

B2;

penDown();

}


What is command B1?


forward(100)

 

forward(20)

 

backward(100)

 

backward(20)


What is command B2?


forward(100)

 

forward(20)

 

backward(100)

 

backward(20)

What is B3?



Suppose we have a 5 x 5 image.The pixels in the top row are numbered 0 through 4 left to right,the ones in the second row from the to are numbered 5 through 9 left to right, and so on. Suppose there is a 'T' in the middle. The horizontal bar is in the middle of the second row, and 3 pixels wide. The vertical bar is in the middle of the third column and is also 3 pixels wide. Only pixels of the 'T' are black, rest are white.


Suppose we flatten the image into an array(let's call it A, and it is indexed from 0) such that pixel number i goes into the array at index i. What is the index of a pixel in column a and row b? (Note that first row has a=0 and first column has b=0)


5 * j + i

 

5 * j * i

 

5 * i + j

 

5 * i + 5 * j




Which of the indices in the array correspond to black pixels ?


3

 

8

 

11

 

13

What is the total number of white pixels?



For the pixel at index i in the array, what are the corresponding row and column number (first row has row number 0, and second row has 1)?


Note: floor(x) is the largest integer that is less than or equal to x. ceil(x) is the smallest

integer that is greater than or equal to x.


floor(i/5), i%5

 

i%5, floor(i/5)

 

ceil(i/5), i%5

 

floor(i/5)+1, i%5



Why don't we write "abstract" before defining any interface in java


A small manufacturing company is expanding by its business by opening multiple branches across the country. Currently all the database is managed by individual employees on Microsoft Excel or sometimes using Microsoft Access. The company is considering updating to a central database management system comprising of several modules for maintaining their manufacturing, inventory, employees and accounting requirements. You are hired to develop a feasibility report as the first phase of the SDLC cycle including the recommendations on economic, operational, technical aspects of the on-going project. 


Bob employs a painting company that wants to use your services to help create an invoice

generating system. The painters submit an invoice weekly. They charge $30 per hour worked. They

also charge tax – 15%. Bob likes to see an invoice that displays all the information – number of

hours, the charge per hour, the total BEFORE tax and the total AFTER tax. Since this is an invoice, we

also need to display the name of the company (Painting Xperts) at the top of the invoice. Display all

of the information on the screen.


Define Interrupt vector and Interrupt vector table.

How the 8086 microprocessor finds out the actual location of an interrupt service routine for an 

interrupt? Describe with proper diagram.


(a) Write about Oscillator and watchdog timer in ATmega32 microcontroller.

(b) What are the major differences between a microprocessor and a microcontroller?


Suppose, the ADC in Atmega32 is configured to use 4 Volt as its voltage reference. Then Find: 

i. Step size, and

ii. Digital output in decimal, if Vin= 3 V.


Draw the flag register of 80286 depicting the flags. Demonstrate the use of IOPL and Nested task 

Flag.


As information centers are progressively centered on energy efficiency, it gets to be imperative to create Low control usage of the different applications that run on them. Data or Information compression plays a basic part in information centers to reduce storage capacity and communication costs. This work pivot on building a Low control, High performance execution usage for canonical Huffman encoding.

 

Suppose given Letters I, Q, R, A, C, M, P, U, S with following frequencies.  

           

                                  Frequency Table

                       Character          Frequency     

                               I                         20                  

                                   Q                   11                 

                                   R                     8                    

                                   A                                12                  

                                   C                       49

                                   M                           10

                                    P                            5

                                    U                           5

                                    S                           33

                                                       

A.    Create a Single Huffman tree to determine the Binary codes for each character.

B.    Encode the following secret message sequence using Huffman encoding scheme.

  “IQRACAMPUS”

C.    Compress and encode the given Information using Huffman coding Scheme.

   “STAY HOME STAY SAFE”  

LATEST TUTORIALS
APPROVED BY CLIENTS