SlideShare a Scribd company logo
4. The size of instructions can be fixed or variable. What are advantage and disadvantage of
fixed compared to variable? point) eft 2 20 0 C-4131-28 Add suction 131-26 nvaction 125-2 PC
egister daiess mancion 120-16 date 1 regnter 2 nstructien 31-00 eg stcrs Read U ALLu dela tlata
dvts 02 rstend In the above figure (single-cycle implementation), current instruction is SW S1,
4(S2) (SW: Store Word; current addrss for this instruction is 100 in decimal; S1 and $2 are
initially 8). For redundancy, you should write "X" instead of 0 or . You should write the reason
for cach question as well. 5. What is the value of RegDst? (1 point) 6. What is the value of
RegWrite? (I point) 7. What is the value after sign-extension? 1 point) 8. What is the value of
MemRead? (1 point) 9. What is the value of MemtoReg? (1 point) In the above figure, current
instruction is ADDI $1. S2, #-1(which is minus l) (ADDI is ADD Immediate; current address for
this instruction s 100 in decimal and S2 are initially1). For redundancy, you should write “X',
instead of 0 or 1 . You should write the reason for each question as well. 10. What is the value
(immediate value) of instruction [15-0)? Write the value in 6-bit binary (1 point) 11. What is the
value after sign extension? Write the value in 32-bit binary. (I point) 12. What is the value of
Reg Write? (1 point) 13. What is the value of MemtoReg? (1 point) 2/4
Solution
import java.util.AbstractSet; import java.util.Arrays; import java.util.Iterator; import
java.util.NoSuchElementException; /** * Implementation of an abstract set using an array-
based binary tree. This is * used to help teach binary tree's and will have more details explained
in * future lectures. * * @author William J. Collins * @author Matthew Hertz * @param
Data type (which must be Comparable) of the elements in this tree. */ public class
ArrayBinaryTree> extends AbstractSet { /** Entry in the data store where the root node can be
found. */ private static final int ROOT = 0; /** Array used to store the nodes which consist of
this binary tree. */ protected Node[] store; /** Number of elements within the tree. */
protected int size; /** * Initializes this ArrayBinaryTree object to be empty. This creates the
array * in which items will be stored. */ @SuppressWarnings("unchecked") public
ArrayBinaryTree() { store = new Node[63]; size = 0; } /** * Initializes this
ArrayBinaryTree object to contain a shallow copy of a * specified ArrayBinaryTree object.
The worstTime(n) is O(n), where n is the * number of elements in the specified
ArrayBinaryTree object. * * @param otherTree The tree which will be copied to create our
new tree, */ @SuppressWarnings("unchecked") public ArrayBinaryTree(ArrayBinaryTree
otherTree) { store = (Node[]) Arrays.copyOf(otherTree.store, otherTree.store.length); size =
otherTree.size; } public int countLeaves() { } /** * Returns the size of this
ArrayBinaryTree object. * * @return the size of this ArrayBinaryTree object. */
@Override public int size() { return size; } /** * Returns an iterator that will return the
elements in this ArrayBinaryTree, * but without any specific ordering. * * @return Iterator
positioned at the smallest element in this ArrayBinaryTree * object. */ @Override
public Iterator iterator() { return new ArrayTreeIterator(); } /** * Determines if there is at
least one element in this ArrayBinaryTree object * that equals a specified element. The
worstTime(n) is O(n) and * averageTime(n) is O(log n). * * @param obj - the element
sought in this ArrayBinaryTree object. * @return true - if there is an element in this
ArrayBinaryTree object that * equals obj; otherwise, return false. * @throws
ClassCastException - if obj cannot be compared to the elements in * this
ArrayBinaryTree object. * @throws NullPointerException - if obj is null. */ @Override
public boolean contains(Object obj) { return getEntry(obj) != null; } /** * Ensures that
this ArrayBinaryTree object contains a specified element. The * worstTime(n) is O(n) for this
addition. * * @param element Element we want to be certain is contained within this *
ArrayBinaryTree * @return True if the element had not been in ArrayBinaryTree and so was
just * added; false if the element was already in the ArrayBinaryTree and * so did
not need to be added or was null and so cannot be added. */ @Override public boolean
add(E element) { // Null objects cannot be added to this Collection if (element == null) {
return false; } // Handle the easy case when the tree has no elements if (isEmpty()) {
Node root = new Node(element, ROOT); store[ROOT] = root; size++ ; return true;
} // Handle the most common case -- adding the element to the end of the tree. else { int
idx = ROOT; // Find the location where this element should be added in the tree while
(true) { int comp = element.compareTo(store[idx].element); // The Set ADT definition
only allows the Collection to contain a single // copy of an element; if this element had been
previously added, we // should just return false if (comp == 0) { return false;
} // If it is smaller, we should traverse to the left child else if (comp < 0) { idx =
(idx * 2) + 1; } // Otherwise it must be larger, so we should traverse to the right child
else { idx = (idx * 2) + 2; } // When the array is not large enough to hold the
new element at the // location at which it needs to be added

More Related Content

PDF
On the code which has a class in which I implementing a binary tree .pdf
PDF
This file contains a complete array-based MultiSet, but not the code.pdf
PDF
this file has a complete array-based MultiSet, but not the code need.pdf
DOCX
Required to augment the authors Binary Search Tree (BST) code to .docx
PDF
Here is what I got so far, I dont know how to write union, interse.pdf
DOCX
Once you have all the structures working as intended- it is time to co.docx
PDF
BSTNode.Java Node class used for implementing the BST. .pdf
PDF
Everything needs to be according to the instructions- thank you! SUPPO.pdf
On the code which has a class in which I implementing a binary tree .pdf
This file contains a complete array-based MultiSet, but not the code.pdf
this file has a complete array-based MultiSet, but not the code need.pdf
Required to augment the authors Binary Search Tree (BST) code to .docx
Here is what I got so far, I dont know how to write union, interse.pdf
Once you have all the structures working as intended- it is time to co.docx
BSTNode.Java Node class used for implementing the BST. .pdf
Everything needs to be according to the instructions- thank you! SUPPO.pdf

Similar to 4. The size of instructions can be fixed or variable. What are advant.pdf (20)

PDF
Please write in C++ and should be able to compile and debug.Thank yo.pdf
DOCX
Assg 12 Binary Search Trees COSC 2336assg-12.cppAssg 12 Binary .docx
PDF
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
PDF
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
PDF
In this lab, you will be given a simple code for a min Heap, and you.pdf
PDF
So I have this code(StackInAllSocks) and I implemented the method but.pdf
PDF
5. Design and implement a method contains 2 for BinarySearchTree, fu.pdf
PDF
For the code below complete the preOrder() method so that it perform.pdf
PDF
Please Write in CPP.Thank youCreate a class called BinaryTreeDeque.pdf
PDF
ReversePoem.java ---------------------------------- public cl.pdf
DOCX
Assg 12 Binary Search TreesCOSC 2336 Spring 2019April.docx
PDF
Given the following class in Java- public class ThreeTenDynArray-T- {.pdf
PDF
Given the following errors and class in Java- How are these errors fix.pdf
PDF
AnswerNote Driver class is not given to test the DoubleArraySeq..pdf
PDF
Help please!!(Include your modified DList.java source code file in.pdf
PDF
Given below is the completed implementation of MyLinkedList class. O.pdf
PDF
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
PPT
java detailed aadvanced jaavaaaaa2-3.ppt
PDF
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
DOCX
Use the following data set that compares age to average years lef.docx
Please write in C++ and should be able to compile and debug.Thank yo.pdf
Assg 12 Binary Search Trees COSC 2336assg-12.cppAssg 12 Binary .docx
Assignment 9 (Parent reference for BST) Redefine TreeNode by adding .pdf
1)(JAVA) Extend the Binary Search Tree ADT to include a public metho.pdf
In this lab, you will be given a simple code for a min Heap, and you.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdf
5. Design and implement a method contains 2 for BinarySearchTree, fu.pdf
For the code below complete the preOrder() method so that it perform.pdf
Please Write in CPP.Thank youCreate a class called BinaryTreeDeque.pdf
ReversePoem.java ---------------------------------- public cl.pdf
Assg 12 Binary Search TreesCOSC 2336 Spring 2019April.docx
Given the following class in Java- public class ThreeTenDynArray-T- {.pdf
Given the following errors and class in Java- How are these errors fix.pdf
AnswerNote Driver class is not given to test the DoubleArraySeq..pdf
Help please!!(Include your modified DList.java source code file in.pdf
Given below is the completed implementation of MyLinkedList class. O.pdf
package com.java2novice.ds.linkedlist;import java.util.NoSuchEleme.pdf
java detailed aadvanced jaavaaaaa2-3.ppt
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Use the following data set that compares age to average years lef.docx

More from mumnesh (20)

PDF
Poisson distribution] The number of data packets arriving in 1 sec at.pdf
PDF
Problem 1 Create Node class (or use what you have done in Lab4)• .pdf
PDF
One of your friends has several brothers and sisters, each quite dif.pdf
PDF
Malpighiaceae luonanthaceae Ochnaceae Flacourtiaceae O Monilophytes G.pdf
PDF
In JavaWrite a program that reads a text file that contains a gra.pdf
PDF
How does Pb and TCE partition between components of soil (mineral, o.pdf
PDF
Hi, please I need help with the correct answer to the above multiple.pdf
PDF
For which phyla are megaspores a shared trait Bryophyta Monilophyt.pdf
PDF
For Programming Embedded SystemsQ-07 Whcih variable and condition.pdf
PDF
For analysis of Thermodynamic Cycle, we draw T-s or P-h diagram. Why.pdf
PDF
Fill in the blank. A contingency table relates only continuous rando.pdf
PDF
Discuss the dangers associated with hydrogen sulfide in the petro.pdf
PDF
Complete the following paragraph to describe the various reproductive.pdf
PDF
CommunicationsSystems have four basic properties (holism, equi-fi.pdf
PDF
Based on your reading of the GCU introduction and the textbooks, wha.pdf
PDF
Answer using Giardias, Shiga-toxin producing E.coli1.Causative Agn.pdf
PDF
Abraham Shine recently opaned his own accounting fiem on April 1, whi.pdf
PDF
29. This figure shows the principal coronary blood vessels. Which one.pdf
PDF
14. Suppose I have collected the names of people in several separate.pdf
PDF
13. What is the difference between post-consumer recycled materials a.pdf
Poisson distribution] The number of data packets arriving in 1 sec at.pdf
Problem 1 Create Node class (or use what you have done in Lab4)• .pdf
One of your friends has several brothers and sisters, each quite dif.pdf
Malpighiaceae luonanthaceae Ochnaceae Flacourtiaceae O Monilophytes G.pdf
In JavaWrite a program that reads a text file that contains a gra.pdf
How does Pb and TCE partition between components of soil (mineral, o.pdf
Hi, please I need help with the correct answer to the above multiple.pdf
For which phyla are megaspores a shared trait Bryophyta Monilophyt.pdf
For Programming Embedded SystemsQ-07 Whcih variable and condition.pdf
For analysis of Thermodynamic Cycle, we draw T-s or P-h diagram. Why.pdf
Fill in the blank. A contingency table relates only continuous rando.pdf
Discuss the dangers associated with hydrogen sulfide in the petro.pdf
Complete the following paragraph to describe the various reproductive.pdf
CommunicationsSystems have four basic properties (holism, equi-fi.pdf
Based on your reading of the GCU introduction and the textbooks, wha.pdf
Answer using Giardias, Shiga-toxin producing E.coli1.Causative Agn.pdf
Abraham Shine recently opaned his own accounting fiem on April 1, whi.pdf
29. This figure shows the principal coronary blood vessels. Which one.pdf
14. Suppose I have collected the names of people in several separate.pdf
13. What is the difference between post-consumer recycled materials a.pdf

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
Insiders guide to clinical Medicine.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Pre independence Education in Inndia.pdf
PDF
Sports Quiz easy sports quiz sports quiz
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Classroom Observation Tools for Teachers
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
RMMM.pdf make it easy to upload and study
human mycosis Human fungal infections are called human mycosis..pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
TR - Agricultural Crops Production NC III.pdf
Computing-Curriculum for Schools in Ghana
Microbial disease of the cardiovascular and lymphatic systems
01-Introduction-to-Information-Management.pdf
Pharma ospi slides which help in ospi learning
Insiders guide to clinical Medicine.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Final Presentation General Medicine 03-08-2024.pptx
Microbial diseases, their pathogenesis and prophylaxis
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Basic Mud Logging Guide for educational purpose
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Pre independence Education in Inndia.pdf
Sports Quiz easy sports quiz sports quiz
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Classroom Observation Tools for Teachers
STATICS OF THE RIGID BODIES Hibbelers.pdf
RMMM.pdf make it easy to upload and study

4. The size of instructions can be fixed or variable. What are advant.pdf

  • 1. 4. The size of instructions can be fixed or variable. What are advantage and disadvantage of fixed compared to variable? point) eft 2 20 0 C-4131-28 Add suction 131-26 nvaction 125-2 PC egister daiess mancion 120-16 date 1 regnter 2 nstructien 31-00 eg stcrs Read U ALLu dela tlata dvts 02 rstend In the above figure (single-cycle implementation), current instruction is SW S1, 4(S2) (SW: Store Word; current addrss for this instruction is 100 in decimal; S1 and $2 are initially 8). For redundancy, you should write "X" instead of 0 or . You should write the reason for cach question as well. 5. What is the value of RegDst? (1 point) 6. What is the value of RegWrite? (I point) 7. What is the value after sign-extension? 1 point) 8. What is the value of MemRead? (1 point) 9. What is the value of MemtoReg? (1 point) In the above figure, current instruction is ADDI $1. S2, #-1(which is minus l) (ADDI is ADD Immediate; current address for this instruction s 100 in decimal and S2 are initially1). For redundancy, you should write “X', instead of 0 or 1 . You should write the reason for each question as well. 10. What is the value (immediate value) of instruction [15-0)? Write the value in 6-bit binary (1 point) 11. What is the value after sign extension? Write the value in 32-bit binary. (I point) 12. What is the value of Reg Write? (1 point) 13. What is the value of MemtoReg? (1 point) 2/4 Solution import java.util.AbstractSet; import java.util.Arrays; import java.util.Iterator; import java.util.NoSuchElementException; /** * Implementation of an abstract set using an array- based binary tree. This is * used to help teach binary tree's and will have more details explained in * future lectures. * * @author William J. Collins * @author Matthew Hertz * @param Data type (which must be Comparable) of the elements in this tree. */ public class ArrayBinaryTree> extends AbstractSet { /** Entry in the data store where the root node can be found. */ private static final int ROOT = 0; /** Array used to store the nodes which consist of this binary tree. */ protected Node[] store; /** Number of elements within the tree. */ protected int size; /** * Initializes this ArrayBinaryTree object to be empty. This creates the array * in which items will be stored. */ @SuppressWarnings("unchecked") public ArrayBinaryTree() { store = new Node[63]; size = 0; } /** * Initializes this ArrayBinaryTree object to contain a shallow copy of a * specified ArrayBinaryTree object. The worstTime(n) is O(n), where n is the * number of elements in the specified ArrayBinaryTree object. * * @param otherTree The tree which will be copied to create our new tree, */ @SuppressWarnings("unchecked") public ArrayBinaryTree(ArrayBinaryTree otherTree) { store = (Node[]) Arrays.copyOf(otherTree.store, otherTree.store.length); size = otherTree.size; } public int countLeaves() { } /** * Returns the size of this ArrayBinaryTree object. * * @return the size of this ArrayBinaryTree object. */ @Override public int size() { return size; } /** * Returns an iterator that will return the
  • 2. elements in this ArrayBinaryTree, * but without any specific ordering. * * @return Iterator positioned at the smallest element in this ArrayBinaryTree * object. */ @Override public Iterator iterator() { return new ArrayTreeIterator(); } /** * Determines if there is at least one element in this ArrayBinaryTree object * that equals a specified element. The worstTime(n) is O(n) and * averageTime(n) is O(log n). * * @param obj - the element sought in this ArrayBinaryTree object. * @return true - if there is an element in this ArrayBinaryTree object that * equals obj; otherwise, return false. * @throws ClassCastException - if obj cannot be compared to the elements in * this ArrayBinaryTree object. * @throws NullPointerException - if obj is null. */ @Override public boolean contains(Object obj) { return getEntry(obj) != null; } /** * Ensures that this ArrayBinaryTree object contains a specified element. The * worstTime(n) is O(n) for this addition. * * @param element Element we want to be certain is contained within this * ArrayBinaryTree * @return True if the element had not been in ArrayBinaryTree and so was just * added; false if the element was already in the ArrayBinaryTree and * so did not need to be added or was null and so cannot be added. */ @Override public boolean add(E element) { // Null objects cannot be added to this Collection if (element == null) { return false; } // Handle the easy case when the tree has no elements if (isEmpty()) { Node root = new Node(element, ROOT); store[ROOT] = root; size++ ; return true; } // Handle the most common case -- adding the element to the end of the tree. else { int idx = ROOT; // Find the location where this element should be added in the tree while (true) { int comp = element.compareTo(store[idx].element); // The Set ADT definition only allows the Collection to contain a single // copy of an element; if this element had been previously added, we // should just return false if (comp == 0) { return false; } // If it is smaller, we should traverse to the left child else if (comp < 0) { idx = (idx * 2) + 1; } // Otherwise it must be larger, so we should traverse to the right child else { idx = (idx * 2) + 2; } // When the array is not large enough to hold the new element at the // location at which it needs to be added