Questions
PLEASE DONT FORGET TO SOLVE THE ASSIGNMENT QUESTION MOST IMP: Ex1) Download the code from the...

PLEASE DONT FORGET TO SOLVE THE ASSIGNMENT QUESTION MOST IMP:

Ex1) Download the code from the theory section, you will find zipped file contains the code of Singly linked list and Doubly linked list, in addition to a class Student.

In Class SignlyLinkedList,

1. There is a method display, what does this method do?

2. In class Test, and in main method, create a singly linked list objet, test the methods of the list.

3. To class Singly linked list, add the following methods:

a- Method get(int n), it returns the elements in the node number n, assume the first node number is 1. You need to check that n is within the range of nodes in the list, otherwise method get returns null.

What is the complexity of your method? Test the method in main.

b- Method insertAfter(int n, E e), its return type is void, it inserts element e in a new node after the node number n, assume the first node number is 1. You need to check that n is within the range of nodes in the list, otherwise through an exception.

What is the complexity of your method?

Test the method in main.

c- Method remove(int n): it removes the node number n, and returns the element in that node, assuming the first node number is 1. You need to check that n is within the range of nodes in the list, otherwise method get returns null.

What is the complexity of your method?

Test the method in main.

d- Method reverse( ): it has void return type. It reverse the order of the elements in the singlylinked list.

What is the complexity of your method?

Test the method in main.

Ex2) In Class DoublyLinkedList

1. There are two methods printForward, printBackward, what do they do?

2. In class Test, and in main method, create a doubly linked list objet, test the methods of the list.

4. To class Doubly linked list, add the following methods:

e- Method get(int n), it returns the elements in the node number n, assume the first node number is 1. You need to check that n is within the range of nodes in the list, otherwise method get returns null.

To make your code more efficient, you should start from the end (header or trailer) that is closer to the target node.

What is the complexity of your method?

Test the method in main.

f- Method insertAfter(int n, E e), its return type is void, it inserts element e in a new node after the node number n, assume the first node number is 1. You need to check that n is within the range of nodes in the list, otherwise through an exception. . To make your code more efficient, you should start from the end (header or trailer) that is closer to the target node.

What is the complexity of your method?

Test the method in main.

g- Method remove(int n): it removes the node number n, and returns the element in that node, assuming the first node number is 1. You need to check that n is within the range of nodes in the list, otherwise method get returns null. To make your code more efficient, you should start from the end (header or trailer) that is closer to the target node.

What is the complexity of your method?

Test the method in main.

Assignment:

To class DoublyLinedList, add method remove(E e) which removes all nodes that has data e. This method has void return type.

doubly package:

doublylinkedlist class:

package doubly;

public class DoublyLinkedList <E>{
   private Node<E> header;
   private Node<E> trailer;
   private int size=0;
   public DoublyLinkedList() {
       header=new Node<>(null,null,null);
       trailer=new Node<>(null,header,null);
       header.setNext(trailer);
   }
   public int size() { return size;}
   public boolean isEmpty() {return size==0;}
   public E first()
   {
   if (isEmpty()) return null;
       return header.getNext().getData();
   }
   public E last()
   {
       if (isEmpty()) return null;
           return trailer.getPrev().getData();
   }
  
   private void addBetween(E e, Node<E> predecessor, Node<E> successor)
   {
       Node<E> newest=new Node<>(e,predecessor,successor);
       predecessor.setNext(newest);
       successor.setPrev(newest);
       size++;
      
   }
   private E remove(Node<E> node)
   {
       Node<E> predecessor=node.getPrev();
       Node<E> successor=node.getNext();
       predecessor.setNext(successor);
       successor.setPrev(predecessor);
       size--;
       return node.getData();
   }
   public void addFirst(E e){
       addBetween(e,header,header.getNext());
   }
   public void addLast(E e){
       addBetween(e,trailer.getPrev(),trailer);
   }
  
   public E removeFirst(){
       if(isEmpty()) return null;
       return remove(header.getNext());
   }
  
   public E removeLast()
   {
   if(isEmpty()) return null;
   return remove(trailer.getPrev());
   }
   public void printForward()
   {
       for (Node<E> tmp=header.getNext();tmp!=trailer;tmp=tmp.getNext())
           System.out.println(tmp.getData());
   }
  
   public void printBackward()
   {
       for (Node<E> tmp=trailer.getPrev();tmp!=header;tmp=tmp.getPrev())
           System.out.println(tmp.getData());
   }
  
  
}

node class:

package doubly;

public class Node <E>{
   private E data;
   private Node<E> prev;
   private Node<E> next;
  
   public Node(E d, Node<E> p,Node<E> n)
   {
   data=d;
   prev=p;
   next=n;
   }
   public E getData() { return data; }
   public Node<E> getNext(){ return next; }
   public Node<E> getPrev(){ return prev; }
   public void setNext(Node<E> n) { next=n;}
   public void setPrev(Node<E> p) { prev=p;}

}

student class:

package doubly;

public class Student {
private int id;
private String name;
public Student(int id, String name) {
   super();
   this.id = id;
   this.name = name;
}
public int getId() {
   return id;
}
public void setId(int id) {
   this.id = id;
}
public String getName() {
   return name;
}
public void setName(String name) {
   this.name = name;
}
@Override
public String toString() {
   return "[id=" + id + ", name=" + name + "]";
}

}

test class:

package doubly;

public class Test {
public static void main(String arg[])
{
   DoublyLinkedList<Student> myList=new DoublyLinkedList<>();
   myList.addFirst(new Student(1,"Ahmed"));
   myList.addFirst(new Student(2,"Khaled"));
   myList.addLast(new Student(3,"Ali"));
   myList.removeLast();
   myList.printForward();
  
  
  
  
}
}

singly package:

node class:

package Singly;

public class Node <E>{
   private E data;
   private Node<E> next;
   public Node(E d, Node<E> n)
   {
   data=d;
   next=n;
   }
   public E getData() { return data; }
   public Node<E> getNext(){ return next; }
   public void setNext(Node<E> n) { next=n;}

}

SinglyLinkedList class:

package Singly;

public class SinglyLinkedList <E>{
   private Node<E> head=null;
   private Node<E> tail=null;
   private int size=0;
   public SinglyLinkedList() { }
   public int size() { return size;}
   public boolean isEmpty() {return size==0;}
   public E first()
   {
   if (isEmpty()) return null;
       return head.getData();
   }
   public E last()
   {
       if (isEmpty()) return null;
           return tail.getData();
   }
   public void addFirst(E e)
   {
   head=new Node<>(e,head);
   if(size==0)
       tail=head;
   size++;

   }
   public void addLast(E e)
   {
   Node<E> newest=new Node<>(e,null);
   if(isEmpty())
       head=newest;
   else
       tail.setNext(newest);

   tail=newest;
   size++;
   }

   public E removeFirst()
   {
       if(isEmpty()) return null;
       E answer=head.getData();
       head=head.getNext();
       size--;
       if (size==0)
           tail=null;
       return answer;
   }
   public E removeLast()
   {
   if(isEmpty()) return null;
   E answer=tail.getData();
   if (head==tail)
       head=tail=null;
   else
   {
   Node<E> tmp=head;
   while (tmp.getNext()!=tail)
       tmp=tmp.getNext();
   tmp.setNext(null);
   tail=tmp;
   }
   size--;
   return answer;
   }
public void display() {
   for (Node<E> tmp=head;tmp!=null;tmp=tmp.getNext())
       System.out.println(tmp.getData());
}
}

Student class:

package Singly;

public class Student {
private int id;
private String name;
public Student(int id, String name) {
   super();
   this.id = id;
   this.name = name;
}
public int getId() {
   return id;
}
public void setId(int id) {
   this.id = id;
}
public String getName() {
   return name;
}
public void setName(String name) {
   this.name = name;
}
@Override
public String toString() {
   return "[id=" + id + ", name=" + name + "]";
}

}
test class:

package Singly;

public class Test {
public static void main(String arg[])
{
   SinglyLinkedList<Student> myList=new SinglyLinkedList<>();
   myList.addFirst(new Student(1,"Ahmed"));
   myList.addFirst(new Student(2,"Khaled"));
   myList.addLast(new Student(3,"Ali"));
   Student x=myList.removeLast();
  
   myList.display();
   System.out.println(myList.size());
  
}
}

In: Computer Science

Customer is saying website is running slow when his end clients are trying to access the...

Customer is saying website is running slow when his end clients are trying to access the site. Say for example this is a "Web Server" running "Apache" and "Tomcat" at the backend. It’s the Web Server that the customer is trying to access. They are trying to place an order, but the application is very slow to load. The server is responding slowly to a user request. How would you troubleshoot this scenario?

In: Computer Science

Note: The answers to the following questions should be typed in the block of comments in...

Note: The answers to the following questions should be typed in the block of comments in the Assignemnt2.java file. Please make sure they're commented out (green). Type them neatly and make them easy to read for the graders.

Given the String object called myString with the value "Practice makes perfect!" answer the following questions.

Question #1 (1pt): Write a statement that will output (System.out) the number of characters in the string.
Question #2 (1pt): Write a statement that output the index of the character ‘m’.
Question #3 (1 pt): Write a statement that outputs the sentence in uppercase letters

Question #4 (1 pt): Write a statement that uses the original string to extract the new string "perfect" and prints it to the screen
Question # 5 (2 pts): What do the following expressions evaluate to in Java given int x = 3, y = 6;

a) x==y/2
b) x%2==0||y%2!=0 c) x–y<0&&!(x>=y) d) x+6!=y||x/y<=0

Question # 6 (1 pt): What does the following statement sequence print? (page 63)

String str = “Harry”;
int n = str.length();
String mystery = str.substring(0,1) + str.substring(n-1, n);
System.out.println(mystery);

In: Computer Science

Python Describe the procedure for setting up the display of an image in a window.

Python

Describe the procedure for setting up the display of an image in a window.

In: Computer Science

Given an array of positive integers a, your task is to calculate the sum of every...

Given an array of positive integers a, your task is to calculate the sum of every possible a[i] ∘a[j], where a[i]∘a[j] is the concatenation of the string representations of a[i] and a[j] respectively.

Example

  • For a = [10, 2], the output should be concatenationsSum(a) = 1344.
    • a[0] ∘a[0] = 10 ∘10 = 1010,
    • a[0] ∘a[1] = 10 ∘2 = 102,
    • a[1] ∘a[0] = 2 ∘10 = 210,
    • a[1] ∘a[1] = 2 ∘2 = 22.

So the sum is equal to 1010 + 102 + 210 + 22 = 1344.

  • For a = [8], the output should be concatenationsSum(a) = 88.

There is only one number in a, and a[0] ∘a[0] = 8 ∘8 = 88, so the answer is 88.

Input/Output

  • [execution time limit] 3 seconds (java)
  • [input] array.integer a

A non-empty array of positive integers.

Guaranteed constraints:
1 ≤ a.length ≤ 105,
1 ≤ a[i] ≤ 106.

  • [output] integer64
    • The sum of all a[i] ∘a[j]s. It's guaranteed that the answer is less than 253.

[Java] Syntax Tips

In: Computer Science

Increase all of the listing prices by 5% for all listings under $500,000 and 10% for...

Increase all of the listing prices by 5% for all listings under $500,000 and 10% for all listings $500,000 and higher. Update the listings table with the new prices.

update LISTING
set LISTING_PRICE = LISTING_PRICE +
case
  when LISTING_PRICE < 500000 then (LISTING_PRICE*5)/100
  when LISTING_PRICE >= 500000 then (LISTING_PRICE*10)/100
  else 0
end

-- Add 30 days to the date expires for all listings.

update LISTING set DATE_EXPIRES = DATEADD(dd, 30, DATE_EXPIRES)

-- Add "Listing updated on [current date]." to the remarks. Replace [current date] with the current systems date. Do not replace the remarks currently in the table. Add these remarks to the remarks already in the table.

update LISTING set REMARKS=CONCAT(REMARKS ," ","Listing updated on ",GETDATE())

-- Return the following information from the listings table from the stored procedure to display the information in the new real estate app: address, city, state, zip, updated listing price, updated date expires, and updated remarks.

CREATE PROCEDURE DISPLAYLISTING
AS
BEGIN
select ADDRESS,CITY,STATE,ZIP,LISTING_PRICE,DATE_EXPIRES,REMARKS from LISTING;
END;

-- Call and run the stored procedure to make the appropriate updates and return the proper results.

In order to execute the stored procedures we use the following SQL script :

EXEC DISPLAYLISTING;

We can update and display the information from the listings table using following stored procedure as :

CREATE PROCEDURE DISPLAYLISTING
AS
BEGIN

update LISTING
set LISTING_PRICE = LISTING_PRICE +
case
  when LISTING_PRICE < 500000 then (LISTING_PRICE*5)/100
  when LISTING_PRICE >= 500000 then (LISTING_PRICE*10)/100
  else 0
end;

update LISTING set DATE_EXPIRES = DATEADD(dd, 30, DATE_EXPIRES);
  
update LISTING set REMARKS=CONCAT(REMARKS ," ","Listing updated on ",GETDATE());

select ADDRESS,CITY,STATE,ZIP,LISTING_PRICE,DATE_EXPIRES,REMARKS from LISTING;

END;

For this lab exercise you will be working with and modifying the stored procedure you created in the last module. In your stored procedure, the first three requirements performed updates to your database and the last two requirements returned the data that was updated. Perform the following:

1. Enclose the code for the first requirement in its own single transaction with the proper commit and rollback functions.

2. Enclose the code for both the second and third requirements in one single transaction with the proper commit and rollback functions.

3. Call and run the stored procedure to make the appropriate updates and return the proper results. Take the appropriate screenshots to show this working and insert into your screenshot document.

4. In the second transaction you created that included the code for the second and third requirements - create an error in the middle of the transaction between the code for the two requirements. For example, you can add an insert or an update statement that uses a field that does not exist. This would cause an error. When you run it, the error should cause the entire transaction to rollback. Because of this error, no changes should be made by this transaction. This is one way of testing your rollback code.

5. Call and run the stored procedure a second time to make the appropriate updates and return the proper results. The first transaction should run without any issues but the second transaction should rollback any changes it made.

You are going to take the stored procedure you created in the lab exercise from the last module and create two transactions within it. The first transaction will contain the first requirement from that module's lab exercise. The second transaction will contain the second and third requirements from that module's lab exercise. You will run it and take screenshots to show it working properly. Then you will purposely insert code to create an error in the middle of the second transaction, in between the two items to cause the transaction to fail and rollback any changes. You will run it again and take screenshots to show your rollback working properly.

In: Computer Science

Use fork() Create a program that reads characters from an input file. Use fork to create...

Use fork()

Create a program that reads characters from an input file. Use fork to create parent and child processes.

The parent process reads the input file. The input file only has letters, numbers. The parent process calculates and prints the frequency of the symbols in the message, creates the child processes, then prints the information once the child processes complete their execution.

The child processes receives the information from the parent, generates the code of the assigned symbol by the parent, and saves the generated code into a file.

Example:

Input.txt: aaaannnaaakkllaaaaap

Output.txt:

a frequency = 12

n frequency = 3

k frequency = 2

l frequency = 2

p frequency = 1

Original Message: aaaannnaaakkllaaaaap

In: Computer Science

A sample human input file that contains test values that a human would enter on the...

A sample human input file that contains test values that a human would enter on the keyboard (covering both normal cases and boundary/error cases)

My code is to search the puzzle, read human_input.txt and then search the word

I have a problem with this line : while(fgets(humanchar, 1000, humanfile)),

searchfirst(array,height,width,"happy"); is search well but searchfirst(array,height,width,humanchar); is nothing happen

In addition, The input may contain upper and lower case characters, I try to convert it to lowercase, but i have a problem, so help me with it "you should convert them all to lower case when you read them."

And finally help me to reverse the word in each search

human_input.txt

search_puzzle.txt
happy
error
hope
exit

searchpuzzle.txt

10 7
ABCDEFt
SsGKLaN
OPpRcJW
PLDrJWO
ELKJiIJ
SLeOJnL
happyTg
BEoREEa
JFhSwen
ALSOEId

test.c

#include <stdio.h>
#include "functions.h"
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

int fileio()
{   FILE *humanfile;
    char humanchar[1000];
   FILE *ptr_file;
   char buf[1000];
   int height,width;
   char **array; //create double pointer array
   // open human_input file
   humanfile = fopen("human_input.txt", "r");
       if (!humanfile)
       {
            printf("File is not available \n");
       return 1;
       }
   char filename[10];
   // get a name of puzzle file
   fscanf(humanfile,"%s",filename);
   //open puzzle file
   ptr_file =fopen(filename,"r");
   if (!ptr_file){
       printf("File is not available \n");
       return 1;
   }
   fscanf(ptr_file,"%d %d",&height,&width); // get height and weight
   printf("%d ",height);
   printf("%d",width);
   printf("\n");
   //allocate array
   array = (char **)malloc(sizeof(char *)*height); // create the array size
   for(int i = 0; i<height;i++){
       array[i] = (char *)malloc(sizeof (char) * width);
   }  
  
   int col = 0, row;
   //get a single char into array
   for(row=0; row<height; row++){
       fscanf(ptr_file, "%s", buf);
       for (int i =0; i <= width;i++){
           if (buf[i] != '\0'){
               array[row][col] = buf[i];
               col++;
       }
       }
       col = 0;
   }

   // print array
   for (int i = 0; i < height; i++) {
       for (int j = 0; j < width; j++){
           printf("%c", array[i][j]);
       }
       printf("\n");
   }
       //close file

   //////////////////////test/////////////////////////////////////////
   //   searchfirst(array,height,width,"happy"); // find the letter
   //   searchfirst(array,height,width,"EId"); // find the letter
       //searchfirst(array,height,width,"tNW");
       //searchfirst(array,height,width,"RwI");
       //searchfirst(array,height,width,"Eed");
       //searchfirst(array,height,width,"PDJ");
      
       //searchfirst(array,height,width,"Ryn");
       //searchfirst(array,height,width,"OsC");
       //searchfirst(array,height,width,"Eea");
       //searchfirst(array,height,width,"LhRynJ");
   /////////////////////////////////////////////////////////////////////
  
   //get a single char into array
  
   // human input I have problem with this one
   while(fgets(humanchar, 1000, humanfile)) {
        // printf("%s\n", humanchar);
           searchfirst(array,height,width,humanchar);
   }
      

       free(array);
       fclose(humanfile);
       fclose(ptr_file);
   return 0;
}

void searchfirst(char **array,int height,int width,char str[]){
// go through array
   for (int i = 0; i < height; i++) {
       for (int j = 0; j < width; j++){
           if (array[i][j] == str[0]){ /// find the first letter in string
           //printf("\nfound %s\n",str);  
           findwordhorizontal(array,i,j,str); //find the word horizontal
           findwordvertical(array,i,j,height,str); // find the word vertical
           findworddiagonal1(array,i,j,height,width,str);
           findworddiagonal2(array,i,j,width,str);
       }  
       }  
   }
}

void findwordhorizontal(char **array,int m,int n,char str[]){

   char *buffer = (char *) malloc(sizeof(char)*(n));  
   int j = 0;
   while (str[j] != '\0'){
       buffer[j] = array[m][n+j]; // add string to buffer
       j++;
   }
   buffer[j] = '\0';//add \0 to ending of string buffer
   int result = strcmp (buffer,str); // comparing string
   if (result==0) // if 2 string equal
   {
       printf("Found the word horizontal %s\n", buffer);      
   }
   free(buffer);
  
}

void findwordvertical(char **array,int n,int m,int height,char str[]){

   char *buffer = (char *) malloc(sizeof(char)*(height ));  
   int j = 0;
   while (n<height){
       buffer[j] = array[n][m]; // add string to buffer
       buffer[j+1] = '\0';//add \0 to ending of string buffer
       int result = strcmp (buffer,str); // comparing string
       if (result==0) // if 2 string equal
       {
           printf("Found the word vertical %s\n", buffer);      
       }
       n++;
       j++;
  
   }
   free(buffer);
}

void findworddiagonal1(char **array,int n,int m,int height,int width,char str[]){
   int count;
   for (count = 0; str[count]; count++){
       // just count length of str
   }  
  
   int calculate1 = width - m; // width - current col
   int calculate2 = height -n; // height - current row
  
   if ( calculate1 >= count && calculate2 >= count){ // if current n m have enough length of str: start searching
       char *buffer = (char *) malloc(sizeof(char)*(calculate1));  
       int j = 0;
       while (j<count){
           buffer[j] = array[n][m]; // add string to buffer
           buffer[j+1] = '\0';//add \0 to ending of string buffer
           //printf("%s vs %s\n",buffer,str);
           int result = strcmp (buffer,str); // compa4 7ring string
           if (result==0) // if 2 string equal
           {
               printf("Found the word diagonal 1 %s\n", buffer);      
           }
           n++;
           m++;
           j++;  
   }
   }
  
}

void findworddiagonal2(char **array,int n,int m,int width,char str[]){
   int count;
   for (count = 0; str[count]; count++){
       // just count length of str
   }  
  
   int calculate1 = width - m; // width - current col
   int calculate2 = n+1; // height - current row
   //printf("%d %d %d\n",calculate1,calculate2,count);
   if ( calculate1 >= count && calculate2 >= count){ // if current n m have enough length of str: start searching
       char *buffer = (char *) malloc(sizeof(char)*(calculate1));  
       int j = 0;
       while (j<count){
           buffer[j] = array[n][m]; // add string to buffer
           buffer[j+1] = '\0';//add \0 to ending of string buffer
           //printf("%s vs %s\n",buffer,str);
           int result = strcmp (buffer,str); // comparing string
           if (result==0) // if 2 string equal
           {
               printf("Found the word diagonal 2 %s\n", buffer);      
           }
           n--;
           m++;
           j++;  
   }
   }
  
}
int main()
{
   fileio();
   return 0;
}

In: Computer Science

Design and inplement a synchronous counter that counts.

Design and inplement a synchronous counter that counts.

In: Computer Science

Q. Compare and contrast Ripple-Carry Adder and Carry-Look ahead Adder 1) In a 4-bit ripple-carry adder...

Q. Compare and contrast Ripple-Carry Adder and Carry-Look ahead Adder

1) In a 4-bit ripple-carry adder as shown in Figure 5.2, assume that each full-adder is implemented using the design as shown in Figure 3.11 (a) and each single logic gate (e.g., AND, OR, XOR, etc.) has a propagation delay of 10 ns. What is the earliest time this 4-bit ripple-carry adder can be sure of having a valid summation output? Explain how you reached your answer and how you did your calculations.

In: Computer Science

1. How are a buffer and a NOT gate similar? 2. How are a buffer and...

1. How are a buffer and a NOT gate similar?

2. How are a buffer and a NOT gate different?

3. When interfacing an Arduino output to a higher voltage, explain how a buffer could be used.

4. What diagram do we use to code the AND function?

5. What diagram do we use to code the OR function?

6. Draw the international diagram for an AND gate.

7. Draw the international diagram for an OR gate.

8. Draw, the truth table for a 3 input AND gate, including the output.

9. Draw the truth table for a 3 input OR gate, including the output.

10. When does 1 + 1 = 1?

In: Computer Science

Cybersecuirty Describe the different types of firewalls that are on the market and how they differ...

Cybersecuirty

Describe the different types of firewalls that are on the market and how they differ from one another. Please write one paragraph fully explaining.

In: Computer Science

Submission Guidelines This assignment may be submitted for full credit until Friday, October 4th at 11:59pm....

Submission Guidelines

This assignment may be submitted for full credit until Friday, October 4th at 11:59pm. Late submissions will be accepted for one week past the regular submission deadline but will receive a 20pt penalty. Submit your work as a single HTML file. It is strongly recommended to submit your assignment early, in case problems arise with the submission process.

Assignment

For this assignment, you will write a timer application in HTML and JavaScript.

Your HTML document should contain the following elements/features:

  1. HTML tags:
    1. An <input> tag labeled "Timer Duration" with the initial value 0
    2. A <button> tag labeled "Start"
  2. Script: When the user presses the button (1b), a function will begin that does the following:
    1. Reads the value from the input field (1a)
    2. Removes the <input> and <button> tags (1a & 1b)
    3. Creates a new <p> tag, initialized to show the input value
    4. Starts a timer that ticks down to zero. For every second that elapses, the paragraph tag (2c) will show the updated timer value (i.e., one less)
    5. When the timer reaches zero, the countdown will stop and the paragraph tag (2c) will be removed and be replaced by a <button> tag labeled "New Timer"
    6. When the <button> tag (2e) is pressed, it will be removed and the <input> and <button> tags (1a, 1b) will be recreated with their original formats

Evaluation

Your assignment will be graded according to whether all the required elements are present and in the correct formats and all required functionalities are operable.

In: Computer Science

Need to program a maze traversal program using dynamic array and stacks. The problem is faced...

Need to program a maze traversal program using dynamic array and stacks. The problem is faced in setting up the data structure and due the problem in setting the data structure other functions like moving in all direction, marking the current cell that is visited are showing the error.

The work so far is below:

const int R = 5; //Number of rows
const int C = 5; //Number of columns

class coordinate
{
public:
int v;
int h;
};

class stack
{
public:
coordinate x;
coordinate y;
};

The maze looks like:

# # S _ #

_ _ _ # #

_ # # _ #

_ _ # # #

_ _ _ _ G

where S = starting point, G = end point, _ = space for moving around and # = wall

In: Computer Science

Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow...

Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example output for userNum = 40:

20 10 5 2 1

In java

import java.util.Scanner;

public class DivideByTwoLoop {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
int userNum;

userNum = scnr.nextInt();

*insert code*

System.out.println("");
}
}

In: Computer Science