Old 6th April 2008, 06:27   #1
dlinkwit27
has no CT
(Forum King)
 
dlinkwit27's Avatar
 
Join Date: Sep 2000
Posts: 13,235
Send a message via ICQ to dlinkwit27 Send a message via AIM to dlinkwit27 Send a message via Yahoo to dlinkwit27
I hate c++

Quote:
Dictionary.cpp: In constructor `Dictionary:ictionary()':
Dictionary.cpp:20: no match for `Dictionary::HashEntry& =
Dictionary::HashEntry*&' operator
Dictionary.h:34: candidates are: Dictionary::HashEntry&
Dictionary::HashEntry:perator=(const Dictionary::HashEntry&)
apollo%
Why!
!Line Number!

.h
code:
enum EntryType{ACTIVE, EMPTY, DELETED};

!34! struct HashEntry{
string data;
EntryType info;

HashEntry(){
info=EMPTY;
}
HashEntry(string s){
data=s;
info=ACTIVE;
}

HashEntry(string s, EntryType i){
data=s;
info=i;
}

};

int primes[10];

HashEntry *h;



.cpp
code:
h=new HashEntry[211];
for(int i=0; i<211; i++)
!20! h[i]=new HashEntry("", EMPTY);
this->used=0;
this->curPrime=0;





ARGH!
dlinkwit27 is offline   Reply With Quote
Old 6th April 2008, 15:28   #2
dlinkwit27
has no CT
(Forum King)
 
dlinkwit27's Avatar
 
Join Date: Sep 2000
Posts: 13,235
Send a message via ICQ to dlinkwit27 Send a message via AIM to dlinkwit27 Send a message via Yahoo to dlinkwit27
I've got it kinda working so far. I hate this assignment
dlinkwit27 is offline   Reply With Quote
Old 6th April 2008, 20:33   #3
k_rock923
\m/
(Forum King)
 
k_rock923's Avatar
 
Join Date: Jul 2003
Location: /bin/bash
Posts: 7,850
Send a message via AIM to k_rock923
What's the assignment?

Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway.
k_rock923 is offline   Reply With Quote
Old 7th April 2008, 00:20   #4
dlinkwit27
has no CT
(Forum King)
 
dlinkwit27's Avatar
 
Join Date: Sep 2000
Posts: 13,235
Send a message via ICQ to dlinkwit27 Send a message via AIM to dlinkwit27 Send a message via Yahoo to dlinkwit27
Implement a dictionary using a hash table and quadratic probing
dlinkwit27 is offline   Reply With Quote
Old 7th April 2008, 08:04   #5
will
Nullsoft Newbie (Moderator)
 
will's Avatar
 
Join Date: Mar 2001
Location: Sheffield, England
Posts: 5,569
you've probably already realised this, but the array of hashentrys should be declared as:
HashEntry **h;
h = HashEntry*[211];

Because you're storing an array of pointers (the new operator gives you a pointer), and an array is declared as a pointer to your datatype, your array is a pointer to a pointer to your type.

To put it another way, the statement "h[x]" is the same as "*(h+x)". So you as your code is, this gives a "HashEntry", not a "HashEntry*" type (which is what you want).

If you don't want to be storing an array of pointers, then you should use h[x] = HashEntry(...); and give your class a proper copy constructor.

DO NOT PM ME WITH TECH SUPPORT QUESTIONS
will is offline   Reply With Quote
Old 7th April 2008, 17:08   #6
dlinkwit27
has no CT
(Forum King)
 
dlinkwit27's Avatar
 
Join Date: Sep 2000
Posts: 13,235
Send a message via ICQ to dlinkwit27 Send a message via AIM to dlinkwit27 Send a message via Yahoo to dlinkwit27
Oh, well the assignment was already turned in, but I will keep that in mind for the next one, which will find the shortest path in a graph from a given node to all other nodes.
dlinkwit27 is offline   Reply With Quote
Old 7th April 2008, 17:20   #7
k_rock923
\m/
(Forum King)
 
k_rock923's Avatar
 
Join Date: Jul 2003
Location: /bin/bash
Posts: 7,850
Send a message via AIM to k_rock923
Have you been assigned traveling salesman?

Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway.
k_rock923 is offline   Reply With Quote
Old 7th April 2008, 20:46   #8
dlinkwit27
has no CT
(Forum King)
 
dlinkwit27's Avatar
 
Join Date: Sep 2000
Posts: 13,235
Send a message via ICQ to dlinkwit27 Send a message via AIM to dlinkwit27 Send a message via Yahoo to dlinkwit27
nope
Quote:
You are to develop a C++ class that represents a weighted, directed graph. You may represent your graph using either of the two standard graph representations discussed in class. Your class must CLEARLY use either an adjacency matrix or an adjacency list representation. Your class should provide at least the following public methods:
  • ReadGraph should accept the name of a file and read in a new graph from that file.
  • TopologicalSort should print to standard output a topological sort of the graph or an error message indicating that a topological sort of the graph is not possible.
  • ShortestPath should accept a node name and print to standard output the cost and the actual path to each other vertex that can be reached (one vertex per line). Must use Dykstra’s algorithm. Do not print anything for vertices that cannot be reached.
  • MinimumSpanningTree should print to standard output the weight of the minimum spanning tree and a list of the edges in the tree along with the weight of each (one edge per line). For the purposes of this process, treat the graph as undirected (that is – ignore the direction of edges). You method may have the graph being connected as a precondition (but your comments better make it clear if you do).
If you are allocating memory dynamically, your class MUST handle it correctly.
You must also write a program that provides a menu to a user allowing the user to input graphs and perform the various graph operations. Your menu should be clear and easy to use, conforming to good user interface standards. It must allow for the reading of multiple graphs in a single run of the program.
dlinkwit27 is offline   Reply With Quote
Old 9th April 2008, 15:04   #9
xzxzzx
Forum King
 
xzxzzx's Avatar
 
Join Date: Aug 2002
Posts: 7,254
The only thing I *know* about C++ is that I don't *know* C++.

Freedom of speech is the basic freedom of humanity. When you've lost that, you've lost everything.
1\/\/4y 34|<$p4y 1gp4y 33714y, 0d4y 0uy4y? | Roses are #FF0000; Violets are #0000FF; chown -R ${YOU} ~/base
The DMCA. It really is that bad. : Count for your life.
xzxzzx is offline   Reply With Quote
Old 9th April 2008, 15:09   #10
ryan
not fucked, not quite.
(Forum King)
 
ryan's Avatar
 
Join Date: Feb 2002
Location: Tn
Posts: 8,798
Send a message via AIM to ryan
cout and cin is about all I remember
ryan is offline   Reply With Quote
Old 9th April 2008, 15:09   #11
k_rock923
\m/
(Forum King)
 
k_rock923's Avatar
 
Join Date: Jul 2003
Location: /bin/bash
Posts: 7,850
Send a message via AIM to k_rock923
For the minimum spanning tree, you want either Prim's or Kruskal's algorithm.


Dijkstra's algorithm is the way to go for shortest path first. In fact, it's often the algorithm used in OSPF routing.

Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway.
k_rock923 is offline   Reply With Quote
Old 10th April 2008, 17:14   #12
dlinkwit27
has no CT
(Forum King)
 
dlinkwit27's Avatar
 
Join Date: Sep 2000
Posts: 13,235
Send a message via ICQ to dlinkwit27 Send a message via AIM to dlinkwit27 Send a message via Yahoo to dlinkwit27
I currently have a single array mimicking a 2d array that I will use, but I will make a Stack of "edges" which will be used for the sorts. What I am worried about is checking for cycles.
dlinkwit27 is offline   Reply With Quote
Old 10th April 2008, 18:07   #13
k_rock923
\m/
(Forum King)
 
k_rock923's Avatar
 
Join Date: Jul 2003
Location: /bin/bash
Posts: 7,850
Send a message via AIM to k_rock923
I believe checking for cycles is bes done with a variation of either breadth or depth first search.

I can't remember which one it was the last time I did it. I think it was depth first.

I'll leave it to you to figure out exactly how it works, but those search algorithms should be a good starting point.

Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway.
k_rock923 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Community Center > General Discussions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump