Questions
How do directories access eachother in a direct accessed allocation file system (i. E where I...

How do directories access eachother in a direct accessed allocation file system (i. E where I nodes access data blocks directly). So if the directory test wanted to access the directory Foo, what steps would have to be taken using blocks and writing to disk?

In: Computer Science

In this exercise you will apply you new understanding of class design to develop an advanced...

In this exercise you will apply you new understanding of class design to develop an advanced version of the array helper class we created in the classroom. This variation of the design will maintain the data stored in the array in an ordered fashion (0 -100 for our int storage) . The class should always maintain its stored data in order meaning at any time if the programmer iterates the items, they will come back in order. This means each time an item is added it must be inserted at the correct location (sorted). Use the unordered class we created in the classroom as your example. The logic of the member functions will be different since the new class needs to keep things ordered and some methods don't make sense in the context of an ordered array like insertAt(). This function isn't needed because the insertion in an ordered array depends on what is already in the array.

You will also add a bulk loading overload for the constructor that takes an array of ints as its parameter and loads the array in an ordered fashion when the object is instantiated. This should also be available as a public method (function) so that the user can clear the array and load it up again with just two function calls (reset() and then load()).

Below is the UML for the two objects. Use your existing code from class as a template for creating this class. You can use just a header file or both a header and implementation file. Which every you choose you must also include a main that runs through all of the methods to test their functionality.

My code .hpp file

class OrderedArrayADT

{

private:

static const int max_size = 100;

int length;

int data[max_size];

void initialize()

{

for(int i = 0; i < max_size; i ++)

{

data[i] = 0;

}

length = 0;

}

  

public:

OrderedArrayADT()

{

initialize();

}

  

void addItem(int item)

{

data[length] = item;

length++;

  

// logic for ordered array add item:

add (int itemToBeInserted) {

int tempStorage = 0;

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

if (data[i] > itemToBeInserted) {

// positon to insert is found

tempStorage = data[i];

data[i] = itemToBeInserted;

//shift items

}

  

  

}

}

// end of logic

}

int replaceItem(int replace, int replaceWith)

{

for(int i = 0; i < length; i++)

{

int oldValue = 0;

if (data[i] == replace)

{

oldValue = data[i];

data[i] = replaceWith;

return oldValue;

}

}

return 0;

}

void removeItem(int item)

{

bool flag = false;

for(int i = 0; i < length; i++ )

{

if(data[i] == item || flag == true)

data[i] = data[i + 1];

flag = true;

}

  

}

  

int sumArray()

{

int total = 0;

for(int i = 0; i < length; i++)

{

total += data[i];

}

return total/length;

}

  

double averageArray()

{

  

return sumArray() / length;

}

  

void resetArray()

{

initialize();

}

  

int getItem(int position)

{

return data[position];

}

  

int getLength()

{

return length;

}

int stored (int item)

{

  

}

  

  

};

cpp file

#include <iostream>

#include "OrderedArray.h"

using namespace std;

int main()

{

OrderedArrayADT specialArray;

specialArray.addItem(12);

specialArray.removeItem(12);

   // specialArray.getItem(4);

cout << specialArray.averageArray();

for(int i = 0; i < specialArray.getLength(); i ++)

{

cout << specialArray.getItem(i);

}

specialArray.stored(int item);

return 0;

}

//Many errors in the cpp file

In: Computer Science

in java we need to order a list , if we create a program in java...

in java we need to order a list , if we create a program in java what  are the possible ways of telling your program how to move the numbers in the list to make it sorted, where each way provides the required result.

list the name of sorting with short explanation

In: Computer Science

There are an infinite number of ways that you can design your Organizational Unit structure within...

There are an infinite number of ways that you can design your Organizational Unit structure within Active Directory. There are four generally accepted methods that are considered best practice:

  • Political/Functional

  • Geographic

  • Resource-based

  • User classification

Discuss pro/cons of one of these methods or discuss a different methodology on OU structure.

In: Computer Science

Write a C++ program (using pointers and dynamic memory allocation only) to implement the following functions...

Write a C++ program (using pointers and dynamic memory allocation only) to
implement the following functions and call it from the main function. (1)Write a function whose signature looks like (char*, char) which returns true if the 1st parameter cstring contains the 2nd parameter char, or false otherwise.

(2)Create an array of Planets. Populate the array and print the contents of the array
using the pointer notation instead of the subscripts.

In: Computer Science

Provide a scenario that illustrates an example of: A breach to confidentiality A breach to integrity...

  • Provide a scenario that illustrates an example of:

    1. A breach to confidentiality

    2. A breach to integrity

    3. A breach to availability

In: Computer Science

I am trying to create my own doubly linkedlist class and here is what I have...

I am trying to create my own doubly linkedlist class and here is what I have so far. my addfirst is adding elements forever and ever, and I could use some help. This is in C++. Please help me complete my doubly linkedlist class. the addfirst method is what I would like to complete.

#ifndef DLLIST_H
#define DLLIST_H
#include "node.h"
#include
using namespace std;
template
class DLList
{
private:


    Node* head = nullptr;
    Node* tail = nullptr;
    T data;
    // private DLList stuff goes here
public:
    // public DLList stuff goes here
    DLList();
    DLList(const DLList&L);
    DLList& operator=(const DLList &L);
    ~DLList();
    void addFirst(T data);
    void addElement(int position, T data);
    void remove(int position);
    void printElements();
    void removeFirst();
    bool exists(T value);
};
template
DLList::DLList(){
    head = nullptr;
    tail = nullptr;
    this ->data = data;
}


template
DLList::DLList(const DLList&L){
     L.head = head;
     while(L.head != nullptr){
         L.data = head->data;
         head = head -> next;
     }
     L.tail = tail;
     L.data = data;
}

template
DLList&DLList::operator=(const DLList &L){
     L.head = head;
     while(L.head != nullptr){
         L.data = head->data;
         head = head -> next;
     }
     L.tail = tail;
     L.data = data;
}

template
DLList::~DLList(){

}


template
void DLList::printElements(){
      Node* curr = head;
      while(curr != nullptr){
          cout << curr->data;
      }

}
template
//create new node
//set appropriate data
//set next to current head
//set nodes prev to nullptr
//set past heads previous to node
void DLList::addFirst(T data){
     Node* node = new Node();
     node->setData(data);
     if(head == nullptr){
         head = node;
         head -> next = nullptr;
         head -> prev = nullptr;
     }
     else{
     node -> next = head;
     node -> prev = nullptr;
     head -> prev = node;
     }
}


template
//create node with data
//traverse to find the area to insert
//adjust the pointers
void DLList::addElement(int position,T data){
    Node* node = new Node();
    node->setData(data);
    Node* curr = new Node();
    curr -> head;
    for(int i = 0; i < position - 1; i++){
         curr = curr -> next;
    }
    node -> prev = curr -> prev;
    curr -> prev = node;
    node -> next = curr;
    node -> prev -> next = node;

}

template
void DLList::remove(int position){
     Node* curr = head;
     Node* next = curr;
     for(int i = 0; i < position - 1; i++){
         curr = curr -> next;
     }
     curr -> prev = nullptr;
     curr -> next = nullptr;
     curr -> prev -> next = curr -> next;
}

template
void DLList::removeFirst(){
   Node* curr = head;
   curr -> next -> prev = nullptr;
   curr -> next = nullptr;

}

template
bool DLList::exists(T value){
    Node* curr = head;
    while(curr != nullptr){
        if(curr->data == value){
            return true;
        }
       curr = curr-> next;
    }
    return false;
}


#endif // DLLLIST_H

//here is my node class for reference.

#ifndef NODE_H
#define NODE_H
using namespace std;
template
class Node{
private:
    T data;
    Node* next;
    Node* prev;
    template
    friend class DLList;
public:
    Node();
    Node(const Node& N);
    T& getData();
    void setData(T data);
    Node* getNext();
    Node* getPrev();
    /*Node():next(nullptr),prev(nullptr){}
    Node(T val):next(nullptr),prev(nullptr),data(val){}
    Node(const Node& rhs):next(nullptr),prev(nullptr),data(rhs.data){}
    ~Node();*/
};

template
Node::Node(){
    next = nullptr;
    prev = nullptr;
}

template
Node::Node(const Node& N){
    N.next = next;
    N.prev = prev;
    N.data = data;
}

template
T& Node ::getData(){
    return data;
}

template
void Node:: setData(T data){
    this -> data = data;
}

template
Node* Node::getNext(){
   return next;
}

template
Node* Node::getPrev(){
    return prev;
}

/*template
Node::Node(T data){
     this->data = data;
}

template
T Node::getData(){
    return this -> data;
}

template
Node::~Node(){

}*/


#endif // NODE_H

In: Computer Science

I need write a small "c" program that has locations of items on a shelving unit....

I need write a small "c" program that has locations of items on a shelving unit. Im not familiar with this language. Can you guys give me some hint so I could start writing one or as example. This is my first time learning programming C.

Specifically, your program should:

  • Contain a struct representing an item on the shelf. It needs only contain the item's name and price.
  • Ask the user for the number of shelves in the unit, and the number of "slots" available on each shelf which can hold items.
  • From the above, build a two dimensional array of item structs. The array represents locations on the shelving unit (rows = shelves, columns = slots on the shelves).
  • Allow the user to add items to the shelves by giving the name, price, and location by reading input in the format: <name>, <price>, <shelf>, <slot>
  • Allow the user to indicate they are done adding items. At this point the user should be able to enter the coordinate of an item in the shelving unit and the program should print out the information about the selected item (or some message if that slot is empty).

In: Computer Science

Write a C++ program to list all solutions of x1 + x2 + x3 = 10....

Write a C++ program to list all solutions of x1 + x2 + x3 = 10.

x1, x2, and x3 are non-negative integers.

In: Computer Science

Here is a program that computes Fibonacci series. Can you add comments to variables and functions...

Here is a program that computes Fibonacci series.
Can you add comments to variables and functions of every functions? For example, what are these variables meaning? What "for" function do on this program?
Describe important section of code to text file. For example, which section of this code important? Why?
Thank you all of help.

#include<iostream>
using namespace std;

int main()
{
   int arr[100];
   
   int n1, n2;
   cin>>n1;
   
   arr[0] = 0;
   arr[1] = 1;
   for(int i = 2;i<n1;i++){
      arr[i] = arr[i-1]+arr[i-2];
   }
   cout<<arr[n1-1]<<endl;
   cin>>n2;
   
   bool found = false;
   for(int i = 0;i<n1;i++){
      if(arr[i] == n2){
         found = true;
         break;
      }
   }
   
   if(found){
      cout<<n2<<" is a Fibonacci number"<<endl;
   }
   else{
      cout<<n2<<" is not a Fibonacci number"<<endl;
   }
   
   for(int i = 0;i<10 && i<n1;i++){
      cout<<arr[i]<<" ";
   }
   cout<<endl;
   return 0;
}

In: Computer Science

Write a Python program that represents various geometric shapes. Each shape like rectangle, square, circle, and...

  1. Write a Python program that represents various geometric shapes. Each shape like rectangle, square, circle, and pentagon, has some common properties, ex. whether it is filled or not, the color of the shape, and number of sides. Some properties like the area of the shapes are determined differently, for example, area of the rectangle is length * widthand area of a circle is ??2. Create the base class and subclasses to represent the shapes. Create a separate test module where instances of the class are created, and the methods are tested by giving the required details and printing the details for each class


I did Already half of the question can you please complete on it cause this is what is required:(The Circle Test Code didn't work please redo the Circle and complete the question requirements:

class Shape:

    def __init__(self,color,fn,no_of_sides):
        self.color=color
        self.filledornot=fn
        self.no_of_sides=no_of_sides
        self.sides = []

    def inputSides(self):
        for i in range(self.no_of_sides):
            self.sides.append(float(input("Enter side " +str(i+1)+" : ")))


    def display(self):
        print("color: " , self.color)
        print("Filled: ", self.filledornot)
        for i in range(self.no_of_sides):
            print("Side ",i+1,"is", self.sides[i])

    def area(self):
        print("Area")

class Rectangle(Shape):

    def __init__(self):
         Shape.__init__(self,"Red",True,2)

    def area(self):
        l , w = self.sides
        calarea=l*w
        print("Area=" , calarea , "cm**2")


class Circle(Shape):
    '''Class to represent the circle shape'''

    # constructor
    def _init_(self):
        Shape.__init__(self, "White", True, 0)

    # area function for the circle
    def area(self):
        radius = self.sides[0]
        area_circle = 3.14*radius*radius
        print("Area= ", area_circle)

#Test Code
print('Rectangle')
r = Rectangle()
r.inputSides()
print('-'*30)
r.display()
r.area()
print('-'*30)

print('Circle')
c = Circle()
c.inputSides()
print('-'*30)
c.display()
c.area()
print('-'*30)

In: Computer Science

EXPLAIN HOW caching WORK FOR BELOW SCENARIO IN HOTELS AND EXPLAIN caching METHODS,PROCEDURES IN DETAIL BELOW...

EXPLAIN HOW caching WORK FOR BELOW SCENARIO IN HOTELS AND EXPLAIN caching METHODS,PROCEDURES IN DETAIL BELOW FOR SCENARIO IN HOTELS

1)TOPIC: caching

SCENARIO: Radison blu hotel concierge services

In: Computer Science

1. Maintain two arrays for use in “translating” regular text to “leetspeak”: (a) One array will...

1. Maintain two arrays for use in “translating” regular text to “leetspeak”:
(a) One array will contain the standard characters:
char[] letters = {'a', 'e', 'l', 'o', 's', 't'}; (b) The other will contain the corresponding symbols:
char[] symbols = {'@', '3', '1', '0', '$', '7'};
2. Prompt the user to enter a full sentence with all lower-case characters, then store it in a variable to be
used later.
(a) You can (optionally) manually convert the string to all lower-case with the String method called
toLowerCase(), for example:
String one = "Hello, World!";
String two = one.toLowerCase(); System.out.println(two); // Output: hello, world!
3. Convert the input string to an array of characters.
4. Then, use a loop to iterate the array of characters and, for each one, check to see if it is in the letters
array: if it is, replace with the corresponding element (i.e. same index) in the symbols array. (a) For example, if the user inputs leetspeak the output should be 1337$p3@k.
2

5. Next,“reset”thecharacterarraytomatchtheoriginalinputstring–youcanjustusethe.toCharArray() command again.
6. Now, prompt the user for a positive integer, store it in a variable. This will be a shift for a basic “Caesar Cipher”.
7. Finally, loop the character array and, if the character is not a space, display: (a) Show the character itself
(b) Show the corresponding ASCII code by converting it to an int. See the following example code of type casting between int and char:
char myChar = 'd';
int myInt = 5;
int combined = myChar + myInt;
System.out.println(myChar); // d
System.out.println((int) myChar); // 100
// NB: when doing addition, they become an int if you don't specify System.out.println(myChar + myInt) // 105
System.out.println((char) combined); // i
(c) Show the result of adding the user’s integer to the ASCII code and converting back to a char.
i. When you add, you want to “wrap around” from z back to a. So to accommodate this, you can use the modulus operator, % along with some clever arithmetic.
ii. For example, if the user enters 5 for the shift value, and you have the character x (ASCII value 120), the result should be c (ASCII value 99); likewise, if the character is b (ASCII value 97) the result would be g (ASCII value 103).
8. Either with a new for-loop, or in the one above, change the elements of the character array by adding the integer to each one. Then display the “shifted” sentence to the user. This is known as the “Caesar Cipher”, and was an early form of sending encrypted messages; you just need to know what the shift value was in the beginning, then subtract it out from the message you receive!


Java

In: Computer Science

You will develop code in the ​StickWaterFireGame​ class only. Your tasks are indicated by a TODO....

You will develop code in the ​StickWaterFireGame​ class only. Your tasks are indicated by a TODO. You will also find more instructions in the form of comments that detail more specifically

what each part of the class is supposed to do, so make sure to read them. ​Do not delete or modify the method headers in the starter code!
Here is an overview of the TODOs in the class.

TODO 1: Declare the instance variables of the class. Instance variables are private variables that keep the state of the game. The recommended instance variables are:

1. A variable, “rand” that is the instance of the Random class. It will be initialized in a constructor (either seeded or unseeded) and will be used by the getRandomChoice() method.
2. A variable to keep the player’s cumulative score. This is the count of the number of times the player (the user) has won a round. Initial value: 0.

3. A variable to keep the computer’s cumulative score. This is the count of the number of times the computer has won a round. Initial value: 0.

4. A variable to keep the count of the number of rounds that have been played. Initial value: 0.

5. A variable to keep track of if the player has won the current round (round-specific): true or false. This would be determined by the playRound method. Initial value: false.

6. A variable to keep track of if the player and computer have tied in the current round (round-specific): true or false. This would be determined by the playRound method. Initial value: false.

The list above contains the minimum variables to make a working program. You may declare more instance variables as you wish.

TODOs 2 and 3: Implement the constructors. The constructors assign the instance variables to their initial values. In the case of the Random class instance variable, it is initialized to a new instance of the Random class in the constructors. If a constructor has a seed parameter, the seed is passed to the Random constructor. If the constructor does not have a seed parameter, the default (no parameter) Random constructor is called.

TODO 4: This method returns true if the inputStr passed in is one of the following: "S", "s", "W", "w", "F", "f", false otherwise. Note that the input can be upper or lower case.

TODOs 5, 6, 7, 8, 9, 10 These methods just return the values of their respective instance variables.

TODO 11: This is a private method that is called by the playRound method. It uses the instance variable of the Random class to generate an integer that can be “mapped” to one of the three Strings: "S", "W", "F", and then returns that String, which represents the computer’s choice.

TODO 12: The playRound method carries out a single round of play of the SWF game. This is the major, “high-level” method in the class. This method does many tasks including the following steps:

1. Reset the variables that keep round-specific data to their initial values.
2. Assign the computer’s choice to be the output of the getRandomChoice method.
3. Check that the player’s choice is valid by calling isValidInput. If the player's input is not valid, the computer wins by default. This counts as a round, so the number of rounds is incremented. 4. If the player’s choice is valid, the computer's choice is compared to the player's choice in a series of conditional statements to determine if there is a tie, or who wins this round of play according to the rules of the game:

S beats W
W beats F
F beats S
Both have the same choice- a tie.

The player and computer scores are updated depending on who wins. In the event of a tie, neither player has their score updated. Finally, the number of rounds of play is incremented.

Note: Do not duplicate the isValidInput or the getRandomChoice code in playRound. Call these methods from playRound. The point is that delegating tasks to other methods makes the code easier to read, modify and debug.

THE CODE:

1 import java.util.Random;
2
3 /* This class ecapsulates the state and logic required to play the
4 Stick, Water, Fire game. The game is played between a user and the computer.
5 A user enters their choice, either S for stick, F for fire, W for water, and
6 the computer generates one of these choices at random- all equally likely.
7 The two choices are evaluated according to the rules of the game and the winner
8 is declared.
9
10 Rules of the game:
11 S beats W
12 W beats F
13 F beats S
14 no winner on a tie.
15
16 Each round is executed by the playRound method. In addition to generating the computer
17 choice and evaluating the two choices, this class also keeps track of the user and computer
18 scores, the number of wins, and the total number of rounds that have been played. In the case
19 of a tie, neither score is updated, but the number of rounds is incremented.
20
21 NOTE: Do not modify any of the code that is provided in the starter project. Additional instance variables and methods
22 are not required to make the program work correctly, but you may add them if you wish as long as
23 you fulfill the project requirements.
24
25 */
26 public class StickWaterFireGame {
27
28 // TODO 1: Declare private instance variables here:
29
30
31 /* This constructor assigns the member Random variable, rand, to
32 * a new, unseeded Random object.
33 * It also initializes the instance variables to their default values:
34 * rounds, player and computer scores will be 0, the playerWins and isTie
35 * variables should be set to false.
36 */
37 public StickWaterFireGame() {
38 // TODO 2: Implement this method.
39
40 }
41
42 /* This constructor assigns the member Random variable, rand, to
43 * a new Random object using the seed passed in.
44 * It also initializes the instance variables to their default values:
45 * rounds, player and computer scores will be 0, the playerWins and isTie
46 * variables should be set to false.
47 */
48 public StickWaterFireGame(int seed) {
49 // TODO 3: Implement this method.
50
51 }
52
53 /* This method returns true if the inputStr passed in is
54 * either "S", "W", or "F", false otherwise.
55 * Note that the input can be upper or lower case.
56 */
57 public boolean isValidInput(String inputStr) {
58 // TODO 4: Implement this method.
59 return false;
60 }
61
62 /* This method carries out a single round of play of the SWF game.
63 * It calls the isValidInput method and the getRandomChoice method.
64 * It implements the rules of the game and updates the instance variables
65 * according to those rules.
66 */
67 public void playRound(String playerChoice) {
68 // TODO 12: Implement this method.
69 }
70
71 // Returns the choice of the computer for the most recent round of play
72 public String getComputerChoice(){
73 // TODO 5: Implement this method.
74 return null;
75 }
76
77 // Returns true if the player has won the last round, false otherwise.
78 public boolean playerWins(){
79 // TODO 6: Implement this method.
80 return false;
81 }
82
83 // Returns the player's cumulative score.
84 public int getPlayerScore(){
85 // TODO 7: Implement this method.
86 return 0;
87 }
88
89 // Returns the computer's cumulative score.
90 public int getComputerScore(){
91 // TODO 8: Implement this method.
92 return 0;
93 }
94
95 // Returns the total nuber of rounds played.
96 public int getNumRounds(){
97 // TODO 9: Implement this method.
98 return 0;
99 }
100
101 // Returns true if the player and computer have the same score on the last round, false otherwise.
102 public boolean isTie(){
103 // TODO 10: Implement this method.
104 return false;
105 }
106
107 /* This "helper" method uses the instance variable of Random to generate an integer
108 * which it then maps to a String: "S", "W", "F", which is returned.
109 * This method is called by the playRound method.
110 */
111 private String getRandomChoice() {
112 // TODO 11: Implement this method.
113 return null;
114 }
115 }
116

In: Computer Science

An alliteration is a stylistic device in which successive words begin with the same letter (or...

An alliteration is a stylistic device in which successive words begin with the same letter (or sometimes the same sound). In our case we will only consider alliterations that follow the "same letter" property. It is often the case that short words (three letters or less) are inserted to make the sentence make sense. Here are some examples of alliterations:

  • alliteration's artful aid

  • Peter parker's poems are pretty

  • Round the rugged rock the ragged rascal ran

  • Peter Piper picked a peck of pickled peppers

Your program will ignore words that are three letters or less when searching for alliterations. For this program, you may assume that the first word of the sentence is at least 4 letters long. For this part of your lab, you will write a java program that asks the user to enter a sentence, word or phrase, and respond by telling the user if the input is an alliteration.

An example of your program's interactions are shown below:

ALLITERATION DETECTOR

ease enter a sentence: Peter parker's poems are pretty

Your input was: "Peter parker's poems are pretty"

The input is an alliteration

ALLITERATION DETECTOR

Please enter a sentence: Able was I ere I saw Elba

Your input was: "Able was I ere I saw Elba"

The input is not an alliteration

In: Computer Science