answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Crazy boy [7]
1 year ago
6

If a class has member variables that are pointers, you must ensure that you implement ____.

Computers and Technology
1 answer:
DedPeter [7]1 year ago
5 0

Answer:

objects

Explanation:

pointer are used for the objects

You might be interested in
Within a word processing program, predesigned files that have layout and some page elements already completed are called text bo
Angelina_Jolie [31]

Answer:

I think D, Your welcome :)

Explanation:

 

7 0
1 year ago
1. Write a set of routines for implementing several stacks and queues within a single array. Hint: Look at the lecture material
JulsSmile [24]

Answer:

Out of the two methods The 2nd method is a better option for implementing several stacks and arrays using the single array system this is because Method 2 makes efficient use of the available space

Explanation:

A) Method 1 ( Divide the given single array in the size of n/k.)

  • How to use method 1 to implement several stacks involves :

i)  To implement several stacks through an array (x) is by dividing the array in n/k parts.

ii) The k represents the slots in which the different stacks will be placed and the n represents the size of the array x.

iii) If you need to implement at least two stacks place the first stack in the slot of a [0] to a [n/k - 1], and another stack in the slot of a[n/k] to a[2n/k-1].

note: The  disadvantage of this method is that the use of the space of the array is not much efficient. therefore method 2 is better

  • How to use method 1 to implement queues involves :

i) queues can also be implemented through an array. applying the same method above

ii) Divide the array in slots and place the queues in that slots.

This method has a problem with  the efficient utilization of the space.therefore method 2 is preferred

B) Method 2 ( uses the space efficiently ) uses two more arrays to implement stacks which are : Top_array and Next_array

  • how to use method 2 to implement several stacks

i) Store the indexes of the next item that will also be stored in all stacks in this initial stack

ii)The initial actual array is x[] and this will store the stacks.

iii)Simultaneously with several stacks, the stack which contain the free slots in the array x[] will also be maintained.

iv)  The entries of the Top_array[] will be initialized to -1. This implies that all the stacks are empty.

v)  Firstly the entries of the array Next_array[i] will be initialized to i+1, since all the slots initially are free and are pointed to the next slot.

vi) Initialize The top of the free stack that is maintaining the free slots  as 0.

vii)  The complexity of push () (method to insert an element) and pop () (method to delete an element) operations by using this method is O (1).

  • How to use method 2 to implement several queues

The same method applicable to implementing several stacks is used here but with a difference is the presence of three extra arrays which are :

Front_array[] = indicates the number of queues. This array stores the indexes of the front elements of the stacks.

Rear_array[] = determines the sizeof the array k . This array stores the indexes of the last elements of the stacks.

Next_array[] = The array n indicates the size of the single array say x. This array stores the indexes of the next items that is being pushed.

i) The initial actual array is a[] which will store the queues. The free slots will also be maintained.

ii)The entries of the Front_array[] will be initialized to -1. This means  that all the queues are empty initially

ii) Initially the entries of the array Next_array[i] will be initialized to i+1, since all the slots initially are free and are pointed to the next slot.

iv) Apply The complexity of enqueue ()  and dequeue ()  by using this method is O (1).

4 0
2 years ago
A ____ partition contains the data necessary to restore a hard drive back to its state at the time the computer was purchased an
Oxana [17]
The answer is back up
8 0
1 year ago
Read 2 more answers
Digital cellphones use __________ to reduce the size of the channels that are required by scattering the digital fragments of co
Yuri [45]

Digital cellphones use Digital Compression to reduce the size of the channels that are required, by scattering the digital fragments of conversations over many channels

7 0
1 year ago
(Displaying a Sentence with Its Words Reversed) Write an application that inputs a line of text, tokenizes the line with String
Serjik [45]

Answer:

I am writing a JAVA and Python program. Let me know if you want the program in some other programming language.

import java.util.Scanner; // class for taking input from user

public class Reverse{ //class to reverse a sentence

public static void main(String[] args) { //start of main() function body

Scanner input = new Scanner(System.in); //create a Scanner class object

   System.out.print("Enter a sentence: "); //prompts user to enter a sentence

   String sentence = input.nextLine(); // scans and reads input sentence

   String[] tokens = sentence.split(" "); // split the sentence into tokens using split() method and a space as delimiter

   for (int i = tokens.length - 1; i >= 0; i--) { //loop that iterates through the tokens of the sentence in reverse order

       System.out.println(tokens[i]); } } } // print the sentence tokens in reverse order

Explanation:

In JAVA program the user is asked to input a sentence. The sentence is then broken into tokens using split() method. split method returns an array of strings after splitting or breaking the sentence based on the delimiter. Here the delimiter used is space characters. So split() method splits the sentence into tokens based on the space as delimiter to separate the words in the sentence. Next the for loop is used to iterate through the tokens as following:

Suppose the input sentence is "How are you"

After split() method it becomes:

How

are

you

Next the loop has a variable i which initialized to the tokens.length-1. This loop will continue to execute till the value of i remains greater than or equals to 0.

for (int i = tokens.length - 1; i >= 0; i--)

The length of first token i.e you is 3 so the loop executes and prints the word you.

Then at next iteration the value of i is decremented by 1 and now it points at the token are and prints the word are

Next iteration the value of i is again decremented by i and it prints the word How.

This can be achieved in Python as:

def reverse(sentence):

   rev_tokens = ' '.join(reversed(sentence.split(' ')))

   return rev_tokens

   

line = input("enter a sentence: ")

print((reverse(line)))

The method reverse takes a sentence as parameter. Then rev_tokens = ' '.join(reversed(sentence.split(' ')))  statement first splits the sentence into array of words/tokens using space as a delimiter. Next reversed() method returns the reversed sentence.  Next the join() method join the reversed words of the sentence using a space separator ' '.join(). If you want to represent the reversed tokens each in a separate line then change the above statement as follows:

rev_tokens = '\n'.join(reversed(sentence.split(' ')))  

Here the join method joins the reversed words separating them with a new line.

Simply input a line of text and call this reverse() method by passing the input line to it.

4 0
1 year ago
Other questions:
  • Janice is unsure about her future career path she has grown up on her family farm but she is also interested in medicine Janice
    5·1 answer
  • Raj needs to apply sorting to a current list in his Word document.
    11·2 answers
  • A network design engineer has been asked to design the IP addressing scheme for a customer network. The network will use IP addr
    6·1 answer
  • In this exercise, you will create a couple of helper methods for ArrayLists in a class called ArrayListMethods.
    10·1 answer
  • Lyrics = ["I wanna be your endgame", "I wanna be your first string",
    5·1 answer
  • Define a method named roleOf that takes the name of an actor as an argument and returns that actor's role. If the actor is not i
    8·1 answer
  • Television broadcasts were originally delivered by using which technology
    14·1 answer
  • All organizations need good quality cybersecurity to ensure _____. Select 4 options.
    12·2 answers
  • What is Accenture's role in Multi-party Systems?
    12·1 answer
  • You are a security consultant and have been hired to evaluate an organization's physical security practices. All employees must
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!