![]() |
| | #1 |
| Registered User Join Date: Oct 2004
Posts: 1
| Datastructure lab I'm a fellow that has big problems on starting this next datastructure lab in c++. I have so much in my mind right now and I don't know if I'm gonna complete this lab on time. So i'm wondering if there are someone that could help me with this lab? We use at the school visual studio 6.0 Here's the lab description: A) Hash table Now your going to make an article-storage were the articles will be saved in a hash-table for fast prompt accessible. For every article saves the information of the article-number, article-type and the amount articles in the storage. You should be able to “hash” on the article-number( i.e article-number is the key). You should be able to ADD, SEEK and LIST the articles in the storage. The programme shall handle collision with "Separate Chaining” i.e create linked list at collisions. You shall therefore make an array of pointers that initiate to NULL, afterward you should be able to seek and add articles that are missing. At collision you do your linked list. Use here as said a linked list and a string class. Remember when you add an article for the first time to the index, you have to move the NULL-pointer to point at the new post and then link the article last in the list. If an article with that article-number already exist in the list, the numbers on the storage should increase on the one that already existed. Does’nt the articlename correspond, then you could yourself decide how it’s gonna be solved in your programme. Assume from these files(must use) 1. Hash.h 2. Hash.cpp 3. Article.h B) Sorting This task goes out on that you have to implement 3 optional sorting-algorithms. The algorithms shall be choosed so an algorithm works with O(n2), next with O(n log n) and the last one with O(n). Write a programme that at random takes number-values to a file. This file shall be used as indata for sorting. After the sorting, shall the result be written out into a result-file. The result-file shall also be used as indata for sorting, to see how the algorithms works on the already sorted or almost sorted data ( if some values changes). You shall have to create data-files with 5 different quantity of numbers to sort. These values shall be used as indata to respective algorithm. Run the algorithm with indata that is both sorted and unsorted. You shall use these following numbers: 100 000, 200 000, 400 000, 800 000 and 1 600 000 values. Same computer must be used to check all values to have a more fair result and the computer may not work with other things during the process of the sorting. Is it so that your computer makes the sorting too quick or too slow, you may have to change some numbers so you get a better result, NOTE that the quantity of the numbers shall double for each sorting. Every algorithm shall have two variables, compare and swap, that counts how many comparision and copies of values has been made during the sort. These two variables shall be used in comparision between the different algorithms. Registrate also the time the algorithms take when they are used, by using following class: 1. Timer.h 2. Timer.cpp Do a table with your results that contains these facts: • Run with an unsorted and a sorted data • Values for compare and swap for respective run • Time-consumption for respective run Here comes the code for the following files. Code: Code Tags added by Kermi3
1. Hash.h
#ifndef _HASH_H
#define _HASH_H
#include "LinkedList.h"
class Hash
{
public:
Hash();
~Hash();
//...
private:
const int TABLESIZE;
LinkedList *m_table;
};
#endif
2. Hash.cpp
#include "Hash.h"
Hash::Hash() : TABLESIZE(11)
{
m_table = new LinkedList[TABLESIZE];
}
Hash::~Hash()
{
delete[] m_table;
}
3. Article.h
#ifndef _ARTICLE_H
#define _ARTICLE_H
#include "String.h"
class Article
{
public:
Article(int i_key, int i_number, String i_type);
//...
private:
int m_key;
int m_number;
String m_type; //Använd din strängklass
};
#endif
4. Timer.h
#ifndef TIMER_H
#define TIMER_H
class Timer
{
public:
Timer(){ m_startTime = 0; m_stopTime = 0; }
int startTimer(); //Returnerar 0 om timern inte kunde initieras
double stopTimer(); //Returnerar tiden (ms) som förlöpt mellan start och stop
double getTime(); //Hämtar sista tidtagningen i millisekunder
private:
double m_startTime;
double m_stopTime;
double m_frequence;
};
#endif
5. Timer.cpp
#include
#include "timer.h"
int Timer::startTimer()
{
LARGE_INTEGER start, freq;
if(!QueryPerformanceFrequency(&freq))
return 0;
m_frequence = (double) freq.QuadPart;
QueryPerformanceCounter(&start);
m_startTime = (double)start.QuadPart;
return 1;
}
double Timer::stopTimer()
{
LARGE_INTEGER end;
QueryPerformanceCounter(&end);
m_stopTime = (double)end.QuadPart;
return (m_stopTime-m_startTime) * 1000.0 / m_frequence;
}
double Timer::getTime()
{
return (m_stopTime-m_startTime) * 1000.0 / m_frequence;
}
Code Tags added by Kermi3 THANK U ALL! email: elmacopaco@hotmail.com |
| El_Maco is offline |
| | #2 | |
| Registered User Join Date: Sep 2004 Location: California
Posts: 3,020
| Quote:
| |
| bithub is offline |
| | #3 |
| VA National Guard Join Date: May 2004 Location: Manassas, VA USA
Posts: 903
| lmao
__________________
|
| The Brain is offline |
| | #4 |
| #include<xErath.h> Join Date: Jun 2004
Posts: 724
| I have a Hash Table in Java... Do you want that with or without code tags?? |
| xErath is offline |
| | #5 |
| unleashed Join Date: Sep 2003
Posts: 693
| Read this about homework policy : http://cboard.cprogramming.com/annou...ouncementid=39 And this about posting a good question: FAQ: Examples of good questions (General)
__________________ source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense |
| alphaoide is offline |
| | #6 |
| Lead Moderator Join Date: Aug 1998
Posts: 2,574
| I'm am posting this because it appears that you are posting a homework assignment or other project and you are asking for someone else to do all of the work. Please don't ask people to do all your work for you, See the announcement on Homework at the top of the forum to see what is acceptable or PM me. Basically people are happy to help, but they're not going to do it all for you. Show us what you've got, show your code (using code tags), or where you're confused and someone will be happy to help you I'm sure. If it's something that you absolutely don't understand how it works, like you have no clue how qsort works, then ask a general question about the function and I'm sure someone will explain it. Though they may not give you all of the code for it, but someone will explain the concept. On obivous homework questions especially, I also like to remind people of the board's tenth guildeline, while this board is very helpful to people, make sure you have your instructor's permission before seeking help on assignments. While people on these boards are more than happy to help, we discourage people from asking for help on graded work without the instructor's permission, and we claim no repsonsibilty for any cheating or honor violations. Feel free to PM me with any questions. Good Luck, Kermi3 Lead Moderator |
| kermi3 is offline |
| | #7 |
| Lead Moderator Join Date: Aug 1998
Posts: 2,574
| I am posting this because you did not use code tags on this thread. In the furture please use Code Tags. They make your code MUCH easier to read and people will be much more likely to help you if you do. And they'll be happier about helping you ![]() For example: Without code tags: for(int i=0;i<5;i++) { cout << "No code tags are bad"; } With Code Tags: Code: for(int i=0;i<5;i++)
{
cout << "This code is easy to read";
}
I've added code tags for you this time. They can be added by putting [code] at the beginning of your code and [/code] at the end. More information on code tags may be found on the code tag post at the top of every forum. I also suggest you take a look at the board guildlines if you have not done so already. This is a common first post mistake, just remember to use [code] tags in the future and you'll get much more help. If this is your first time posting here the welcome, and if there's anything I can do or any questions I can answer about these forums, or anything else, please feel free and welcome to PM me. Good Luck with your program, Kermi3 Lead Moderator |
| kermi3 is offline |
| | #8 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,693
| Sorry, way too blatant homework for me. The real killer is "please email me" Which really means "I've spammed a shed-load of boards and I can't be arsed to remember where they all are. Plus I've no intention of ever returning to your loser board if none of you idiots don't email me a good answer. If you do provide a good answer, I'll treasure your email address and leech off you for the rest of my course". |
| Salem is offline |
| | #9 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,693
| Wow - 1 post, 2 red boxes and you've only been here for just over an hour. Haven't seen a crash and burn like this since Yucatan 65M years ago |
| Salem is offline |
| | #10 |
| Registered User Join Date: Sep 2004
Posts: 720
| el maco...don't listen to these guys, they're I am sillyI am sillyI am sillyI am sillyI am sillyI am sillyI am sillys....i'll do it for you....e-mail me everything that you have involving this project.. i don't have a domain name for my server yet, but just e-mail it to misplaced@127.0.0.1 |
| misplaced is offline |
| | #12 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,693
| Fortunately, he seems to have faired no better elsewhere either - which is a "good thing" http://www.codeguru.com/forum/showthread.php?t=313359 http://www.flipcode.com/cgi-bin/msg....=general&id=-1 |
| Salem is offline |
| | #13 |
| Toaster Join Date: Aug 2001
Posts: 2,686
| The guy one flipcode had a good response.
__________________ The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop. |
| Zach L. is offline |
| | #14 |
| Code Goddess Join Date: Sep 2001
Posts: 9,664
| >The guy one flipcode had a good response. And people say we're mean.
__________________ My best code is written with the delete key. |
| Prelude is offline |
| | #15 |
| Lead Moderator Join Date: Aug 1998
Posts: 2,574
| Nothing benificial can come from this one. Closed. Will be reopened upon request of thread the author of the thread. |
| kermi3 is offline |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help with programming lab. | woody292 | C++ Programming | 3 | 09-07-2008 11:19 PM |
| Internet Chem Lab | axon | A Brief History of Cprogramming.com | 0 | 02-17-2005 09:12 PM |
| programming from home to the lab??? | nbo10 | Tech Board | 7 | 08-27-2004 04:35 PM |
| Please help debug this lab! Please! | mack_ol | C Programming | 0 | 02-17-2002 12:32 PM |
| stupid computer lab lady... | dirkduck | A Brief History of Cprogramming.com | 7 | 10-16-2001 06:53 PM |