homework

What's Wrong? Question relied on: Files,Exceptions -> ERROR: EOFError

EDITED: import pickle filename=input('Enter a file name:') def entoles(): f=open(filename,'w') names=[] grades=[] while True: name=input("Give a student's name:") if name.lower()=='end': f.close() print("File closed") print("Back to M...

Calculate the depth of a binary search tree?

I am having difficulty calculating the summation of depths [the sum of the individual depths for all children of the root] for a given BST. I have the total number of nodes for the tree, and I am trying to calculate the average depth for the tree, requiring I have this depth sum. Recursion and I don't get along very well.. I am finding ...

do-while stopped working

Back again with another rookie question. While working on a function for my homework project I found that my menu wouldn't exit when I press X, it worked just an hour ago and I haven't changed anything in main(). I commented out all the code in my functions just to be sure that nothing in a function interfered. I just can't find any prob...

Searching through an ArrayList

Implement a method public void search (String searchString) { } to iterate through the notes ArrayList until it finds a note that contains the searchString. It should then print either the item found or the message "String not found". So far, I have: import java.util.ArrayList; import java.util.Iterator; /** * A clas...

Another Lisp function refinement

I've completed the Graham's exercise Chapter 5.8,and my code is: (defun max-min (vec &key (start 0) (end (length vec))) (cond ((eql start (1- end)) (values (elt vec start) (elt vec (1- end)))) ((zerop end) (values nil nil)) (t (multiple-value-bind (x y) (max-min vec :start (1+ start) :end end) (let* ((maxx ...

prefix to infix on stack

I'm trying to implement prefix to infix in c++, that's what i've got so far. The input should be for example something like this: /7+23 And the ouput: 7/(2+3) or (7/(2+3)) But instead I get: (/) That's the code I wrote so far: void pre_to_in(stack<char> eq) { if(nowe.empty() != true) { char test; test = eq.top();...

Searching through an ArrayList of Strings to find text

This is what I have so far but I don't now what to do next. The question is as follows (sorry the coding is not all appearing in one box): Implement a method public void search (String searchString) { } to iterate through the notes ArrayList until it finds a note that contains the searchString. It should then print either the item fou...

How to determine for which value artificial neuron will fire?

I'm trying to determine for the articial neuron shown below the values (0 or 1) for the inputs i1, i2, and i3 for which it will fire (i0 is the input for the bias weight and will always be -1). The weights are W0 = 1.5 W1 = -1 W2 = 1, and W3 = 2. Assume the activation function depicted in image below. Please clarify your answer ...

Prolog - recursing down family tree

I am trying to write a Prolog program that will print out the male successors of British Royalty in order. My attempt so far: son(elizabeth, charles). son(charles, william). son(charles, henry). son(elizabeth, andrew). son(elizabeth, edward). son(edward, severn). successor(X, Y) :- son(X, Y). successor(X, Y) :- son(X, C), successor(C, Y...

C# - How to print objects in an array using for/foreach?

I have a homework assigment to iterate through an object array and print out these objects using for and foreach. I'm stuck on how to do that. Questions When you use a foreach loop, don't you have to declare the object? So the object declared in a foreach loop is null, because it doesn't call any constructors in my Employee class. Cod...

Saving each of this boards into a Data Structure

This is a dumb question and I feel embarrassed to ask it, but I'm pressed for time and I'm burnt out. I have this sambple input: 1 4 2 3 0 5 6 7 8 3 1 2 6 4 5 0 7 8 -1 -1 -1 each group of numbers represents a board of the 8 puzzle, I don't know how many boards will appear on the text file. I only know its end is marked with -1 -1 ...

reseting a flow layout with a button

What I am trying to do here is set the layout scheme once I press a button to align all the buttons to the left of the contentPane I have three buttons this is the code i have for that particular button leftButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cp.setLayout( new FlowLayout(F...

Tackling the 8-puzzle problem via BFS

I've heard that the 8-puzzle problem can be tackled via BFS, but I don't understand how. I wanna know the intermediate steps that I need to get from a board like this: 3 1 2 6 4 5 0 7 8 to 1 2 3 4 5 6 7 8 0 Are the intermediate steps "levels" on a BFS search? By the way, this is basic homework, I don't care about optimality. ...

C++ text menu: writing, reading, and sorting data

Hey guys, So my assignment is to create multiple classes for a Person, Name, ID #, Address, and Phone #. Name makes up: First, Middle, and Last name. ID # makes up: 9 digits. Address makes up: street, city, state, and 5 digit zip code. Phone # makes up: 3 digit area code and 7 digit number. Person makes up: a full Name (First, Middle, L...

Python Ascendance and descendance

Hello, I apologize in advance for the basic level of my question. I would like to the print the: total number and identity of nodes that have 0 child, 1 child, 2 children, 3 children. total number of node that have 0 parent, 1 parent, 2 parents, 3 parents. here is my simple script. thanks. Vicinci search = [] search += search_nodes(...

Changing time mode in a Digital Clock from 12HR to 24HR in VHDL

Greetings everyone. I am designing a digital clock in VHDL which I am supposed to synthesize on a FPGA . I am cascading S1,S2,M1,M2,H1 and H2 where (S1 = second 1, M1 = Minute 1, H1 = hour 1 etc.). One of the requirements is for the clock to switch between 24HR display to a 12HR display format. How do I do it given that H1 and H2 are r...

C++ What is compile-time polymorphism and why does it only apply to functions?

The question is pretty much fully embedded in the title. ...

terminating the input at '=' character

i want to terminate the input at '=' character for example that i have given the input 2 +3= as soon as i give the '=' character it should process the input and display the output. Any help.. Spaces can also be included in the input. (it should not take any input after '=' character) the pl is c++ or c ...

Object-Oriented Execution

Consider the following source snippets: Snippet #1 StoredProcedure sp = new StoredProcedure( "PROC_NAME", getConnection() ); sp.putParameter( "ID", getId() ); sp.execute(); Snippet #2 StoredProcedure sp = new StoredProcedure( "PROC_NAME" ); sp.setConnection( getConnection() ); sp.putParameter( "ID", getId() ); sp.execu...

prolog program for determining whether any two pairs in a list have the same sum

How can I write a relation in prolog that determines if there are any two pairs in a list with the same sum. The relation should fail if there exist no pairs whose sums are equal. The relation should also fail if the list contains less than four elements. list([1 2 3]) fails since it only has 3 elements list([2 3 4 1]) succeeds since...