Jump to content

Can anyone help me decipher this?

Remixt
Go to solution Solved by madknight3,
1 hour ago, Remixt said:

What on gods green earth is a characteristic vector?

Sorry if I'm incorrect but I think it's referring to this. Simple right? Well, I understand if that's also confusing so I'll try to explain it as I understand it.

 

Lets use an easy example (using pseudocode).

// Lets assume you're storing a set of boolean values
// The set of all boolean values is {False, True}
// So the characteristic vector would be
vec = [0,0]

// and here's your currently empty set
set = {}

// vec[0] denotes false
// vec[1] denotes true

// So if you have your own set object and you add false to it.
// Then you change the false location to 1
// Now you have
set = {false}
vec = [1,0]

// Now if you add true to your set you have
set = {false, true}
vec = [1,1]

// if you try to add true or false to your set, you know they already exist
// because the characteristic vector has a 1 in those spots

// Now if you remove false from your set you have
set = {true}
vec = [0,1]

 

Lets take something a little bigger but still easy.

// Lets assume you're storing a set of integer values in the range of 1 and 10 inclusive
// The set of all values is {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
// So the characteristic vector would be

vec = [0,0,0,0,0,0,0,0,0]

// vec[0] denotes 1
// vec[1] denotes 2
// etc

// and here's your currently empty set
set = {}

// So if you have your own set object and you add 5 to it.
// Then you change the 5th location to 1
// Now you have
set = {5}
vec = [0,0,0,0,1,0,0,0,0,0]

// if you try to add 5 to it again you know it already exists
// because the characteristic vector has a 1 in that spot

The same concept can be applied to ASCII characters, or anything that can be represented uniquely by a natural number. Hopefully you are getting the idea.

Okay, so I've been learning C++ trying to catch up with my intermediate class. I just got my programming assignment for the week and I don't really understand what my professor is asking for and he hasn't answered my emails. I really have no idea where to even start.

 

Here is what he wants:

 

As "advertised", you are to complete and submit a C++ implementation of sets that use characteristic vector(s) to represent sets. What on gods green earth is a characteristic vector? Does anyone have an idea of how I can break this down and do it?

CPU: Ryzen 5950X Ram: Corsair Vengeance 32GB DDR4 3600 CL14 | Graphics: GIGABYTE GAMING OC RTX 3090 |  Mobo: GIGABYTE B550 AORUS MASTER | Storage: SEAGATE FIRECUDA 520 2TB PSU: Be Quiet! Dark Power Pro 12 - 1500W | Monitor: Acer Predator XB271HU & LG C1

 

Link to comment
Share on other sites

Link to post
Share on other sites

has your tutor specified anything else other than as "advertised"

intel i7 4790k OC @ 4.6ghz | MSI GTX 980 | MSI gaming 5 MB | 16gb hyperX RAM | Corsair HX750i | Corsair 450D

 

Yes all hackers wear balaklavas and or hoodies with leather gloves when they hack

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, originalNam3 said:

has your tutor specified anything else other than as "advertised"

Yeah there is an example program, 

 

#pragma once
using namespace std;
#include <iostream>
#include <assert.h>

class Set 
{
    public :

    Set();
    Set(const Set& s);    // copy constructor
    ~Set();
    void add(int i);
    void remove(int i);
    int size();
    int is_member(int i);
    void operator=(const Set& s);
    Set operator&(const Set& s);    // intersection
    Set operator|(const Set& s);    // union
    Set operator^(const Set& s);    // exclusive OR
    Set operator-(const Set& s);    // set difference

    void printSet();

    private:   // whatever you want to add, probably including any data 
               // associated with a Set, like maybe an array of unsigned ints
};
 

CPU: Ryzen 5950X Ram: Corsair Vengeance 32GB DDR4 3600 CL14 | Graphics: GIGABYTE GAMING OC RTX 3090 |  Mobo: GIGABYTE B550 AORUS MASTER | Storage: SEAGATE FIRECUDA 520 2TB PSU: Be Quiet! Dark Power Pro 12 - 1500W | Monitor: Acer Predator XB271HU & LG C1

 

Link to comment
Share on other sites

Link to post
Share on other sites

Uh okay...from this wiki link on sets (computer science): https://en.wikipedia.org/wiki/Set_(abstract_data_type) . I think, from what I'm understanding...you're supposed to make a program with a set range and when something inputted is within a some characteristic related to your vector/container you add that value to the vector. so you have a vector called odd; you input 3 into the program. 3 is an odd number so you add it to the odd vector and so on. But there cannot be repeats in your set so if 3 is inputted again you don't store both of them in odd you keep just one.

 

Though I could be entirely wrong and I'm sorry if i have confused you even further

intel i7 4790k OC @ 4.6ghz | MSI GTX 980 | MSI gaming 5 MB | 16gb hyperX RAM | Corsair HX750i | Corsair 450D

 

Yes all hackers wear balaklavas and or hoodies with leather gloves when they hack

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Remixt said:

What on gods green earth is a characteristic vector?

Sorry if I'm incorrect but I think it's referring to this. Simple right? Well, I understand if that's also confusing so I'll try to explain it as I understand it.

 

Lets use an easy example (using pseudocode).

// Lets assume you're storing a set of boolean values
// The set of all boolean values is {False, True}
// So the characteristic vector would be
vec = [0,0]

// and here's your currently empty set
set = {}

// vec[0] denotes false
// vec[1] denotes true

// So if you have your own set object and you add false to it.
// Then you change the false location to 1
// Now you have
set = {false}
vec = [1,0]

// Now if you add true to your set you have
set = {false, true}
vec = [1,1]

// if you try to add true or false to your set, you know they already exist
// because the characteristic vector has a 1 in those spots

// Now if you remove false from your set you have
set = {true}
vec = [0,1]

 

Lets take something a little bigger but still easy.

// Lets assume you're storing a set of integer values in the range of 1 and 10 inclusive
// The set of all values is {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
// So the characteristic vector would be

vec = [0,0,0,0,0,0,0,0,0]

// vec[0] denotes 1
// vec[1] denotes 2
// etc

// and here's your currently empty set
set = {}

// So if you have your own set object and you add 5 to it.
// Then you change the 5th location to 1
// Now you have
set = {5}
vec = [0,0,0,0,1,0,0,0,0,0]

// if you try to add 5 to it again you know it already exists
// because the characteristic vector has a 1 in that spot

The same concept can be applied to ASCII characters, or anything that can be represented uniquely by a natural number. Hopefully you are getting the idea.

Link to comment
Share on other sites

Link to post
Share on other sites

He wants you to implement a set class/structure using characteristic/occurence vectors. It essentially counts the occurrences of values in another vector. Let's say you have a vector with the elements 0,2,1,4,3,2. You then create another vector with the size of the max element in the original vector(+1) . You iterate over the old vector and for each cell you will get a value t. You then make the value at the t index of the characteristic array 1. This means that at all times you will not have duplicates in a set ,and that elements can always be accessed in a specific order , ascending by default. And if you have an already sorted vector, you can more easily find elements in it. (I think it's O(logN) )

i5 4670k @ 4.2GHz (Coolermaster Hyper 212 Evo); ASrock Z87 EXTREME4; 8GB Kingston HyperX Beast DDR3 RAM @ 2133MHz; Asus DirectCU GTX 560; Super Flower Golden King 550 Platinum PSU;1TB Seagate Barracuda;Corsair 200r case. 

Link to comment
Share on other sites

Link to post
Share on other sites

On 2/8/2016 at 4:02 PM, madknight3 said:

Sorry if I'm incorrect but I think it's referring to this. Simple right? Well, I understand if that's also confusing so I'll try to explain it as I understand it.

 

Lets use an easy example (using pseudocode).


// Lets assume you're storing a set of boolean values
// The set of all boolean values is {False, True}
// So the characteristic vector would be
vec = [0,0]

// and here's your currently empty set
set = {}

// vec[0] denotes false
// vec[1] denotes true

// So if you have your own set object and you add false to it.
// Then you change the false location to 1
// Now you have
set = {false}
vec = [1,0]

// Now if you add true to your set you have
set = {false, true}
vec = [1,1]

// if you try to add true or false to your set, you know they already exist
// because the characteristic vector has a 1 in those spots

// Now if you remove false from your set you have
set = {true}
vec = [0,1]

 

Lets take something a little bigger but still easy.


// Lets assume you're storing a set of integer values in the range of 1 and 10 inclusive
// The set of all values is {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
// So the characteristic vector would be

vec = [0,0,0,0,0,0,0,0,0]

// vec[0] denotes 1
// vec[1] denotes 2
// etc

// and here's your currently empty set
set = {}

// So if you have your own set object and you add 5 to it.
// Then you change the 5th location to 1
// Now you have
set = {5}
vec = [0,0,0,0,1,0,0,0,0,0]

// if you try to add 5 to it again you know it already exists
// because the characteristic vector has a 1 in that spot

The same concept can be applied to ASCII characters, or anything that can be represented uniquely by a natural number. Hopefully you are getting the idea.

That makes things easier to understand. I at least have a starting point now. Thank you

CPU: Ryzen 5950X Ram: Corsair Vengeance 32GB DDR4 3600 CL14 | Graphics: GIGABYTE GAMING OC RTX 3090 |  Mobo: GIGABYTE B550 AORUS MASTER | Storage: SEAGATE FIRECUDA 520 2TB PSU: Be Quiet! Dark Power Pro 12 - 1500W | Monitor: Acer Predator XB271HU & LG C1

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×