answersLogoWhite

0

📱

Computer Science

Computer Science is the systematic study of algorithmic processes that describe and transform information. It includes the theoretical foundations of information and computation and the practical techniques of applying those foundations to computer systems. Among the many subfields of Computer Science are computer graphics, computer programming, computational complexity theory, and human-computer interaction. Questions about Computer Science, terms such as algorithms and proofs, and methodologies are encouraged in this category.

1,839 Questions

Distinguish between dfa and nfa?

DFA stands for Deterministic finite automaton and NFA stands for Nondeterministic finite automaton.

Formally, an automaton is made up of: were delta is the transition function. In a DFA, delta takes as input a state and letter and returns only one state. In an NFA, delta takes as input a state and letter but returns a set of states.

An NFA accepts a word iff there exists a run of the automaton on it (intuitively, the automaton guesses an accepting run). A DFA has only one run on every word and therefore accepts a word iff the single run on it is accepting.

Difference between Sr flip-flop nand gate and Sr flip-flop nor gate?

The nand gate variety of the SR flip-flop uses falsevalues to change state with, while the nor gate variety of the SR flip-flop uses true values to change state with.

What is the purpose of head element in HTML?

To provide data about the webpage that is not included in the main body of the webpage, such as title, meta description and tags, CSS style rules and javascript functions.

Example:

Head tag example

The logical address space of the process is 8 pages and the size of each page is 1 Kb There are 64 frames in the main memory The size of a frame is equivalent to the size of a page With the given you?

A part of this question requires re-translating into readable English.

The "size" of a page is 1 Kb. The size of a frame equals the size of a page, so a frame is also 1 Kb. There are to be 64 frames in 8 pages, which would mean 8 frames per page, except that one frame also equals one page?... This is illogical, unless you clarify your definition.

What are the six phases of database design in computer science?

What are the six phases of database design? Discuss each phase.
Database design phases are:

1. Requirements collection and analysis.

2. Conceptual design.

3. Logical design (data model mapping).

4. Physical design.

Why is encapsulation needed?

Imagine that we both work for the same project and first you wrote the code for a class, and then I used your class in my program. Later on, you didn't like the way the class behaved, because some of its instance variables were being set (by me from my code) to values you hadn't anticipated. Their code brought out errors in your code. (Relax, I wont do that, dont worry.) Since, it is a Java program, so you should be able just to ship out a newer version of the class, which I could replace in my programs without changing any of my own code.

The above scenario highlights two of the promises or rather i should say benefits of Object Orientation (OO): flexibility and maintainability. But these benefits will not come automatically. You have to do something. You have to write your classes and code in a way that supports flexibility and maintainability. Just because Java supports OO concepts, it cannot write code for you. Can it?? For example, imagine if you made your class with public instance variables, and those other programmers were setting the instance variables directly, as the following code demonstrates:

public class BadExample {

public int size;

public int weight;

...

}

public class AnotherBadExample {

public static void main (String [] args) {

BadExample b = new BadExample ();

b.size = -5; // Legal but bad!!

}

}

Now go back the scenario we spoke about a paragraph ago. BadExample is your class and AnotherBadExample is my code. I have modified one of your variables in a way that it helps my code logic but that totally alters the way your class works. Now you are in trouble. How are you going to change your class in such a way that no one can alter your values directly (like what i have done in my code)? Your only choice is to write a method say setSize(int newVal) inside your class and then change the access modifier of the variable size to say, private. This will ensure that you handle instances when someone is trying to set a value to the size variable that you dont want and at the same time ensure that no one can access the size variable directly and mess with your code.

But, unfortunately, by doing that, you have broken my code. If I try to compile my AnotherBadExample class, i will get errors because the size variable is no longer visible for me.

How can we address this situation now? The best way is: not write such code where public variables are available for anyone and everyone to modify.

The ability to make changes in your code without breaking the code of all others who use your code is a key benefit of encapsulation. You should always hide implementation details. To elaborate, you must always have your variables as private and then have a set of public methods that others can use to access your variables. Since the methods are public anyone can access them, but since they are in your class you can ensure that the code works the way that is best for you. So in a situation that you want to alter your code, all you have to do is modify your methods. No one gets hurt because i am just using your method names in my code and the code inside your method doesnt bother me much.

If you want maintainability, flexibility, and extensibility (and I guess, you do), your design must include encapsulation. How do you do that?

How do you use Java Native Interface to access Delphi code from Java classes?

The Delphi code would need to be compiled into a DLL, and the DLL is then called from java using the JNI. See http://home.pacifier.com/~mmead/jni/delphi/JavaToDPR/ to get started.

How you get the size of arrays from user?

in c simply add three lines in the begining of your program:

int x;

printf("enter the size of the array to be entered :");

scanf("%d",&x);

after that use x as your maximum limit of array in your program.

in c++ just replace above printf & scanf statements by

cout<<"enter the size of the array to be entered :";

&

cin>>x;

respectively and do not use brackets.

Convert nondeterministic finite automaton to deterministic finite automaton?

The only difference between a NDFSA (non-deterministic finite-state automation) and a DFSA (deterministic finite-state automation) is that a NDFSA can be in several states at once. Therefore, to convert a NDFSA to a DFSA, all that needs to be done is to replace all transitions from a state that puts the FSA into multiple other states with one transition that puts it into a *new* single state (that will represent the multiple states) and will take all transitions off those multiple states.

if we say a.x->b means that from state "a", on input "x", goes to state "b", and have the following NDFSA

a.x->b

a.x->c

b.y->a

c.y->b

c.z->c

..make it a DFSA by:

a.x->b

a.x->c

{ create new state with all ND transitions }

i=(b,c)

i.y->a (from b.y)

i.y->b (from c.y)

i.z->c (from c.z)

{ a.x is now deterministic }

a.x->i

{ continue through each state }

i.y->a

i.y->b

{ make deterministic }

j=(a,b)

j.x->i (from a.x)

j.y->a (from b.y)

{ remove all unreachable states }

a.x->i

i.y->j

i.z->c

j.x->i

j.y->a

c.z->c

Remember that epsilon transitions (transitions a->b (with no x) will cascade), e.g.,

a.x->b

b->c

c->d

{ because "b" reaches "c", and "d" }

i=(b,c,d)

a.x->i

What are objects and how are they created from a class in Java?

Literally, an object in programming is a collection of data and functions (remember that functions just bits of data, too). An object's class defines what those data and functions are and how to make new objects of that class.

So a class is like a cast to make a plastic toy and an object is like a single plastic toy itself.

What is a syndrome?

A syndrome is a collection of recognizable features, behaviors, signs and symptoms (as reported by a patient) which frequently occur together and can be observed or detected collectively to identify a particular illness, genetic disorder or other medical condition.

In some cases a particular syndrome may have only one cause, such as Down Syndrome. Others have multiple possible causes such as Parkinsonian Syndrome (often shortened to Parkinson's), or in many cases the cause may be unknown.

Some syndromes may have limited treatment options or are groups of symptoms and behaviors that may not be treatable or are still under investigation by medical professionals.

The most important distinction to realize is that a syndrome is not a cause of disease or even a disease in and of itself but rather it is the collection of side effects caused by something else.

For example AIDS (Auto Immune Deficiency Syndrome) is the collection of side effects which includes a weak immune system; however, HIV (Human Immunodeficiency Virus) is the actual disease which is contagious. People do not catch AIDS; they catch HIV which than causes the syndrome (or collection of symptoms) known as AIDS. It is a commonly made mistake to use the terms incorrectly. But from a technical standpoint HIV is the virus, and AIDS (which is a syndrome) is the list of side effects.

Shell program to find the sum of cube of individual digits of a number?

Shell problems are programs that can be run to find out information about numbers. The problem can help find an even or odd number, or what the sum of a cube is.

Can you give the explanation for various operations in a queue implementation using arrays?

The following are operations performed by queue in data structures

  • Enqueue (Add operation)
  • Dequeue (Remove operation)
  • Initialize

How do you implement a doubly linked list using only one reference value instead of the usual next and previous references?

store the exor of the previous node address and next node address in each node of single linked list .further exor the nodes to proceed forward or backward as necessary

What are some fun and useful things to do in Terminal for Mac OS X Snow Leopard?

Here are some fun ones, type "telnet towel.blinkenlights.nl" (minus the quotes) then press enter, you can now watch Star Wars in ASCII art! If you type "say "some text here"" and press enter your computer will speak the text you put in between the quotes. Last is a bit complicated but arguably the most fun. Type "emacs" and press enter, press enter again. Now, press ESC + X. You can type in a few things now, type tetris then press enter, and you'll be playing tetris! Type doctor then press enter and you can talk to a virtual psychotherapist. Type snake and you can play the classic snake game!

How do you use prim's algorithm to find a spanning tree of a connected graph with no weight on its edges?

Prims Algorithm is used when the given graph is dense , whereas Kruskals is used when the given is sparse,we consider this because of their time complexities even though both of them perform the same function of finding minimum spanning tree.

ismailahmed syed

What are hot-swappable and hot-pluggable devices?

A device or series of devices referred to as "Hot plugging or hot swapping" means that they can be changed out without having to shut down the main system in order to do so.

Think of a USB thumb drive, how you can plug it in, use it, then disconnect it without ever having to reboot the computer. That is a good example of "Hot swap" technology. It is commonly used in RAID arrays or on device programming setups or disk duplicators.

C programming language bsc it notes?

different between defining value definition section and defining value declaration section

A merge algorithm which will merge two sorted lists into one sorted list?

You have two options here.

For the first you have to ask yourself, "Is my data continuously sorted by the list itself?" If you answered 'yes' then you can simply add all data from one list to the other and the combined list will be sorted.

If you answered 'no' to the above question, then it means you have two lists which are currently sorted, but which may not remain that way if new elements are added to them.

Let's look at some steps to merge all elements list1 and list2 into a separate list3. (We'll assume data is sorted from least to greatest).

1) Start two index counters (one for each list) which point to the start of the list.

2) Is the element at list1[index1] less than the element at list2[index2]?

  1. If so, add list1[index1] to the end of list3 and increment index1.
  2. If not, add list2[index2] to the end of list3 and increment index2.

3) If either index has reached the end of its list, then add the remaining elements from the other list to list3 and we're done.

4) Otherwise, go back to step 2.

Define the concept network topologies?

The various devise in anetwork can be linked in several ways: Sar, bus or Ring

What is the Data structures used for stack?

A stack is a linear last-in first-out list type data structure. Several implementations are possible. Two examples are the array and the linked list.

The array is quick, but is limited in size.

The linked list requires overhead to allocate, link, unlink, and deallocate, but (except for total available memory) is not limited in size.

One compromise might be a linked list of arrays. Another compromise might be to not necessarily unlink and delete when an element is popped off the stack.

How do you convert from base 10 to base 2 without division?

1. Write out the powers of 2 from 20 = 1 (in right to left order, ie ... 16 8 4 2 1) until you get a power greater than or equal to the number you wish to convert.

2. Put a one (1) under the highest power of 2 that is less than or equal to the number

3. Subtract that power from the number.

4. If the result of the subtraction is not zero, find the next power of 2 not greater than the result of the subtraction and repeat from step 3.

5. Put a zero (0) under all powers of 2 which have nothing under them.

6. The result (under the powers of 2) is the number in base 2.

Example to convert 948 base 10 to base 2:

Write out the powers of 2 until greater than or equal to 948:

Powers: 1024...512...256...128...64...32...16...8...4...2...1

First power less than or equal to 958 is 512:

Powers: 1024...512...256...128...64...32...16...8...4...2...1

Result:.....................1.......................................................................

948 - 512 = 436

Next power not greater than 436 is 256:

Powers: 1024...512...256...128...64...32...16...8...4...2...1

Result:.....................1........1..............................................................

436 - 256 = 180 → 128:

Powers: 1024...512...256...128...64...32...16...8...4...2...1

Result:.....................1........1.........1.................................................

180 - 128 = 52 → 32:

Powers: 1024...512...256...128...64...32...16...8...4...2...1

Result:.....................1........1.........1...............1...............................

52 - 32 = 20 → 16

Powers: 1024...512...256...128...64...32...16...8...4...2...1

Result:.....................1........1.........1...............1......1.......................

20 - 16 = 4 → 4:

Powers: 1024...512...256...128...64...32...16...8...4...2...1

Result:.....................1........1.........1..............1......1..........1...........

4 - 4 = 0, so fill in the zeros:

Powers: 1024...512...256...128...64...32...16...8...4...2...1

Result:.....................1........1.........1.......0.....1......1....0...1...0...0

Thus 95810 = 11 1011 01002

(If the powers are written out in ascending order (from left to right), reverse the final result.)