Questions
A disk drive has 300 cylinders, numbered 0 to 299. The drive is currently serving a...

  • A disk drive has 300 cylinders, numbered 0 to 299. The drive is currently serving a request at cylinder 51, and the previous request was at cylinder 56. The pending requests are received in the following order: 72, 56, 103, 111, 17, 189, 236, 198, and 88.
  • FCFS
  • SSTF
  • SCAN

Compare the algorithms and determine which is the fairest for the next process in the queue. Explain why this algorithm will always be the fairest disk-scheduling algorithm.

Describe an example of circumstances where fairness would be an important goal. Describe a scenario where it would be important that the operating system be unfair. Minimum 250 words.

In: Computer Science

Write a function that tells whether a hailstone sequence contains a number that is greater than...

Write a function that tells whether a hailstone sequence contains a number that is greater than 1000.

Write a contract, then an implementation, of a function that takes exactly one parameter, an integer n, and returns true if the hailstone sequence starting with n contains a number that is greater than 1000, and returns false otherwise. The heading must be as follows.

  bool bigHailstone(int n)

This function must not read or write anything.

Your algorithm for bigHailstone must be a search algorithm. As soon as it sees a number that is greater than 1000, bigHailstone must return true without looking at any more numbers in the hailstone sequence starting with n.

Modify your main function so that it also shows whether there is a number that is greater than 1000.


C++

In: Computer Science

1D List Practice Could you write the code to solve the following problem that uses 1D...

1D List Practice

Could you write the code to solve the following problem that uses 1D lists?

You have been tasked with writing a Python program that will assist the CAU Registrar’s Office with determining the following:

  • the average GPA of the freshman class after their first semester
  • the top five GPAs
  • the number of students who are eligible for the Dean’s List (i.e., their GPA is 3.25 or higher)

Your program will contain at least three (3) functions - main, getInfo, and compute - that complete the following tasks:

  • a function named main that “kicks off” the program with a description of what the program will do. It will then call the getInfo function (see below).
  • a function named getInfo reads the file named freshmen.txt and puts the GPAs of the freshman class into a list (named students). This function will then call (with the list as the argument) the compute function (see below).
  • a function compute will calculate and display (to the screen):
    • the average GPA of the freshman class after their first semester
    • the top five GPAs
    • the number of students who are eligible for the Dean’s List (i.e., their GPA is 3.25 or higher)

Note: To test/run your program, you will need to generate a file named freshmen.txt that contains 450 GPAs (each on its own line) that have been randomly generated, ranging from 1.0 to 4.0

In: Computer Science

Write a program that prints and calls two methods. 1. Compute and return the future value...

Write a program that prints and calls two methods.

1. Compute and return the future value of an account based on the present value of the account, the interest rate, and the number of years.

future value = p * (1 + r   / 100) y

Your method should have the following characteristics:

• It should have three double parameters:

  • present value

• interest rate

• number of years

• It should return a double, the future value.

• It should use Math.pow in the calculation.

• It should not have any print statements. The main method should do all the printing.

2. Compute and return the future value of an annuity based on the payment per year, the interest rate, and the number of years.

For each method, the main method needs to obtain input from the user, call the method with the input values, save the result of the method in a local variable, and print the inputs and the result.

future value = p *( (1 + r/100)eY - 1) / r/100

Your method should have the following characteristics:

• It should have three double parameters:

• yearly payment

• interest rate

• number of years

• It should return a double, the future value.

• It should use Math.pow in the calculation.

• It should not have any print statements. The main method should do all the printing.

[ USE JAVA TO WORK ON THIS PROBLEM PLEASE]

_____________________________________________________________________________________________________________________________________________________

# This is my work so far:

import java.util.*;

public class Lab3 {

public static void main(String[] args) {
System.out.println("Lab 3 written by Tesfalem Tekie.");
Scanner input = new Scanner(System.in);
  
System.out.print(" ");// will work on the prompt
double Value = input.nextdouble();
double Rate = input.nextdouble();
double Years = input.nextdouble();
  
double futureValue = account(Value, Rate, Years);
System.out.println(" ");// keep working
double AnnFutureValue = annuity(Value, Rate, Years);
System.out.println(" ");// keep working
}//end main method

public static double account(double preValue, double intRate, double numOfYears ) {
double result = Math.sqrt(p*(1 + r/100)eY);// keep working
return result;
}
public static double annuity(double yearly_pay, double int_rate, double num_of_years) {
double outcome = Math.sqrt(p* ((1 + r/100)eY - 1)/r/100);// keep working
return outcome;
}
  
}//end class method

In: Computer Science

java You are creating an array where each element is an (age, name) pair representing guests...

java

You are creating an array where each element is an (age, name) pair representing guests at a dinner Party.
You have been asked to print each guest at the party in ascending order of their ages, but if more than one
guests have the same age, only the one who appears first in the array should be printed.
Example input:
(23, Matt)(2000, jack)(50, Sal)(47, Mark)(23, will)(83200, Andrew)(23, Lee)(47, Andy)(47, Sam)(150, Dayton)

Example output:

(23, Matt) (47, Mark) (50, Sal (150, Dayton) (2000, Jack) (83200, Andrew)

Read all your party goers from a file. That is passed through the command line.

In your readme:
Describe a solution that takes O (1) space in addition to the provided input array. Your algorithm may modify the input array.
This party has some very old guests and your solution should still work correctly for parties that have even older guests, so your algorithm can’t assume the maximum age of the partygoers.
Give the worst-case tight-O time complexity of your solution.

I have been working on this problem but have been struggling with reading the file and
not getting errors such as no element found.

In: Computer Science

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