comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en
comp.lang.c++@googlegroups.com
Today's topics:
* subset - 7 messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/898bcce92c1b97fc?hl=en
* show all subset of a set - 5 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/708873746ae8ae59?hl=en
* Return by reference - 11 messages, 7 authors
http://groups.google.com/group/comp.lang.c++/t/f6dd94c3223a1dbf?hl=en
* Top 20 coding interview problems asked in Google with solutions: Algorithmic
Approach - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/f0866a8c45ecb553?hl=en
* Cracking Programming Interviews: 500 Questions with Solutions - 1 messages,
1 author
http://groups.google.com/group/comp.lang.c++/t/4532417d39af96b4?hl=en
* Getting Started with a Visual Studio C++ 2013 IDE - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/6af661da9c3466bf?hl=en
==============================================================================
TOPIC: subset
http://groups.google.com/group/comp.lang.c++/t/898bcce92c1b97fc?hl=en
==============================================================================
== 1 of 7 ==
Date: Sat, Feb 8 2014 2:43 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
David Harmon <source@netcom.com> writes:
>The given code looks like:
> int testcase=0;
> cin>>testcase;
> while(i<testcase)
>Now, there are many problems you might pick with that code, but
>anything caused by initializing testcase to a default value in case
>the cin input fails is not among them. Would you rather that the
>subsequent loop go running off to some undetermined possibly huge
>number just because testcase was never given a value?
Yes, otherwise the real error (not checking the stream
state after reading) might remain hidden even longer!
== 2 of 7 ==
Date: Sat, Feb 8 2014 4:05 am
From: David Brown
On 08/02/14 11:33, David Harmon wrote:
> On Fri, 07 Feb 2014 11:04:40 -0800 in comp.lang.c++, Barry Schwarz
> <schwarzb@dqel.com> wrote,
>> Why does the definition of testcase contain initialization?
>
> Because you should never define an uninitialized variable without a
> really good reason!
>
> The given code looks like:
> int testcase=0;
> cin>>testcase;
> while(i<testcase)
>
> Now, there are many problems you might pick with that code, but
> anything caused by initializing testcase to a default value in case
> the cin input fails is not among them. Would you rather that the
> subsequent loop go running off to some undetermined possibly huge
> number just because testcase was never given a value?
>
You should never unnecessarily initialise a variable, because that stops
the compiler checking your code for you.
If you leave "int testcase;" uninitialised, and later use it without
first setting its value, then the compiler's warnings will tell you.
But if you've used "int testcase = 0;", then the compiler can't help you
spot that error.
== 3 of 7 ==
Date: Sat, Feb 8 2014 5:25 am
From: Victor Bazarov
On 2/8/2014 7:05 AM, David Brown wrote:
> On 08/02/14 11:33, David Harmon wrote:
>> On Fri, 07 Feb 2014 11:04:40 -0800 in comp.lang.c++, Barry Schwarz
>> <schwarzb@dqel.com> wrote,
>>> Why does the definition of testcase contain initialization?
>>
>> Because you should never define an uninitialized variable without a
>> really good reason!
>>
>> The given code looks like:
>> int testcase=0;
>> cin>>testcase;
>> while(i<testcase)
>>
>> Now, there are many problems you might pick with that code, but
>> anything caused by initializing testcase to a default value in case
>> the cin input fails is not among them. Would you rather that the
>> subsequent loop go running off to some undetermined possibly huge
>> number just because testcase was never given a value?
>>
>
> You should never unnecessarily initialise a variable, because that stops
> the compiler checking your code for you.
>
> If you leave "int testcase;" uninitialised, and later use it without
> first setting its value, then the compiler's warnings will tell you. But
> if you've used "int testcase = 0;", then the compiler can't help you
> spot that error.
Reliance on compiler warnings can only be done in conjunction with other
ways of ensuring correctness of the code. Code reviews and following
coding standards are other methods. However, in the end there is no
single action that would completely protect of making a mistake.
Besides, warnings are non-normative and therefore are not consistent
from compiler to compiler or even from one version of the same compiler
to another.
That said, a random value is worse than a known one. It can lead to
unpredictable behavior of the program. Repeatability, even if the
actions of the program are incorrect, helps tremendously in fixing the bugs.
V
--
I do not respond to top-posted replies, please don't ask
== 4 of 7 ==
Date: Sat, Feb 8 2014 5:43 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
Victor Bazarov <v.bazarov@comcast.invalid> writes:
>That said, a random value is worse than a known one.
n3290 does not call it »random«:
»if no initialization is performed, an object with automatic
or dynamic storage duration has indeterminate value.«
== 5 of 7 ==
Date: Sat, Feb 8 2014 7:37 am
From: Öö Tiib
On Saturday, 8 February 2014 15:43:03 UTC+2, Stefan Ram wrote:
> Victor Bazarov <v.bazarov@comcast.invalid> writes:
> >That said, a random value is worse than a known one.
>
> n3290 does not call it »random«:
>
> »if no initialization is performed, an object with automatic
> or dynamic storage duration has indeterminate value.«
Victor's point still holds since random is just (more useful) subset
of indeterminate. So if random is worse than known then indeterminate
is even worse.
== 6 of 7 ==
Date: Sat, Feb 8 2014 8:02 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
Öö Tiib <ootiib@hot.ee> writes:
>On Saturday, 8 February 2014 15:43:03 UTC+2, Stefan Ram wrote:
>>Victor Bazarov <v.bazarov@comcast.invalid> writes:
>>>That said, a random value is worse than a known one.
>>n3290 does not call it »random«:
>>»if no initialization is performed, an object with automatic
>>or dynamic storage duration has indeterminate value.«
>Victor's point still holds since random is just (more useful) subset
>of indeterminate.
When someone says: »x e A« (»x is an element of A.«), and
the specs say: »x e B«, and »A c B« (»A is a subset of B«),
then »x e A« does /not/ follow from the specs (from »x e B«).
(It would follow if instead »B c A« would be true.)
Hey, we're on topic again, as the subject says: »subset«!
== 7 of 7 ==
Date: Sat, Feb 8 2014 8:15 am
From: David Brown
On 08/02/14 14:25, Victor Bazarov wrote:
> On 2/8/2014 7:05 AM, David Brown wrote:
>> On 08/02/14 11:33, David Harmon wrote:
>>> On Fri, 07 Feb 2014 11:04:40 -0800 in comp.lang.c++, Barry Schwarz
>>> <schwarzb@dqel.com> wrote,
>>>> Why does the definition of testcase contain initialization?
>>>
>>> Because you should never define an uninitialized variable without a
>>> really good reason!
>>>
>>> The given code looks like:
>>> int testcase=0;
>>> cin>>testcase;
>>> while(i<testcase)
>>>
>>> Now, there are many problems you might pick with that code, but
>>> anything caused by initializing testcase to a default value in case
>>> the cin input fails is not among them. Would you rather that the
>>> subsequent loop go running off to some undetermined possibly huge
>>> number just because testcase was never given a value?
>>>
>>
>> You should never unnecessarily initialise a variable, because that stops
>> the compiler checking your code for you.
>>
>> If you leave "int testcase;" uninitialised, and later use it without
>> first setting its value, then the compiler's warnings will tell you. But
>> if you've used "int testcase = 0;", then the compiler can't help you
>> spot that error.
>
> Reliance on compiler warnings can only be done in conjunction with other
> ways of ensuring correctness of the code. Code reviews and following
> coding standards are other methods. However, in the end there is no
> single action that would completely protect of making a mistake.
> Besides, warnings are non-normative and therefore are not consistent
> from compiler to compiler or even from one version of the same compiler
> to another.
>
That's all true - compiler warnings are an aid to avoiding bugs, but
they certainly don't cover everything. However, appropriate use of
compiler warnings should be a normal part of your development
methodology. If you are using a compiler that does not have a
reasonable level of warnings, then it is a good idea to use an external
tool (a "lint" tool), or simply pass the same code though a compiler
that /is/ good at static error checking. Since gcc is a suitable
choice, and is free, there is no good excuse for not using it as a
minimum (llvm is an alternative).
The worst thing you can do is say that since your compiler is not
perfect at static error checking, you should ignore it!
> That said, a random value is worse than a known one. It can lead to
> unpredictable behavior of the program. Repeatability, even if the
> actions of the program are incorrect, helps tremendously in fixing the
> bugs.
>
In a case like this, the initial value is only ever used if there is a
bug in later code. Giving the variable an initial value hides the bug
from helpful tools, and it certainly does not remove the bug. It is a
far stretch to claim that it makes the bug less bad (by having a known
value rather than an indeterminate one) - the bug is there, and the
program will not work.
==============================================================================
TOPIC: show all subset of a set
http://groups.google.com/group/comp.lang.c++/t/708873746ae8ae59?hl=en
==============================================================================
== 1 of 5 ==
Date: Sat, Feb 8 2014 12:17 pm
From: Dale Fletcher
Öö Tiib wrote:
> On Thursday, 6 February 2014 18:13:54 UTC+2, mary...@gmail.com wrote:
>> allow me explain it with a example.
>>
>> n=3
>> { } 000 0
>> {1} 100 4
>> {2} 010 2
>> {3} 001 1
>> {1,2} 110 6
>> {1,3} 101 5
>> {2,3} 011 3
>> {1,2,3} 111 7
>
> Your illustration seems messed up. Usually we expect to
> see that:
> n=3
> set binary decimal
> { } 000 0
> {1} 001 1
> {2} 010 2
> {1,2} 011 3
> {3} 100 4
> {1,3} 101 5
> {2,3} 110 6
> {1,2,3} 111 7
>
> Lower sub-patterns repeat so it is simple to make it recursive.
> Also like we see the decimal is now linear so it is pointless to
> make it recursive. ;)
Good observation. Then there is a question of unmasking the bits.
== 2 of 5 ==
Date: Sun, Feb 9 2014 12:39 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
Dale Fletcher <dflach@twees.au> writes:
>Good observation. Then there is a question of unmasking the bits.
Do we need vectors assuming that 64-bit integer arithmetic
is available? On one hand, some sets might have more than
64 elements. (In 1997, Harkstrøm et al. reported a set with
more than 3000 elements!) On the other hand, printing all
subsets from a set with more than 64 elements might take
such a long time that it is practically unfeasible, so that
we might not have to worry at all about implementing this.
When one can print 1e9 lines per second (each line containing
a subset specification), it might still take more than
200000 years to print all subsets of a set with 64 elements.
However, during that time computers might become faster,
so that the task could be finished earlier, when the computer
is updated using hot hardware update capabilities while it
executes the program.
== 3 of 5 ==
Date: Sun, Feb 9 2014 3:13 am
From: Öö Tiib
On Sunday, 9 February 2014 10:39:48 UTC+2, Stefan Ram wrote:
> Dale Fletcher <dflach@twees.au> writes:
> >Good observation. Then there is a question of unmasking the bits.
>
> Do we need vectors assuming that 64-bit integer arithmetic
> is available? On one hand, some sets might have more than
> 64 elements. (In 1997, Harkstrøm et al. reported a set with
> more than 3000 elements!) On the other hand, printing all
> subsets from a set with more than 64 elements might take
> such a long time that it is practically unfeasible, so that
> we might not have to worry at all about implementing this.
It is quite optimal to use 'enum', 'std::bitset<32>' or just
'uint32_t' instead of 'std::set<type_that_has_32_states>'. Also
that 'std::bitset<3000>' can be often more viable than
'std::set<type_that_has_3000_states>'. Instead of 'std::vector'
I would suggest 'boost::container::flat_set' that takes care
of set-like behavior of underlying vector there.
> When one can print 1e9 lines per second (each line containing
> a subset specification), it might still take more than
> 200000 years to print all subsets of a set with 64 elements.
> However, during that time computers might become faster,
> so that the task could be finished earlier, when the computer
> is updated using hot hardware update capabilities while it
> executes the program.
The task to output all possible states of a set is indeed not too
useful when the amount of states grows. Learning to output state
of set (in all of its incarnations) is the handy skill there.
== 4 of 5 ==
Date: Sun, Feb 9 2014 3:46 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
Öö Tiib <ootiib@hot.ee> writes:
>It is quite optimal to use 'enum', 'std::bitset<32>' or just
With <cstdint>::std::uint_least64_t one can do arithmetics
and get the next state by just »++«.
#include <iostream>
#include <ostream>
#include <cstdint>
#include <cassert>
void print( int const i, int const num )
{ for( int k = num - 1; k >= 0; --k )
::std::cout <<( char )( i &( 1 << k )? '`' + num - k : ' ' );
::std::cout << '\n'; }
void enumerate( int const num )
{ assert( num <= 64 );
using bits = ::std::uint_least64_t;
bits const top =( bits )1 << num;
for( bits i = 0; i <= top - 1; ++i )print( i, num ); }
int main(){ enumerate( 3 ); }
== 5 of 5 ==
Date: Sun, Feb 9 2014 4:20 am
From: Öö Tiib
On Sunday, 9 February 2014 13:46:59 UTC+2, Stefan Ram wrote:
> Öö Tiib <ootiib@hot.ee> writes:
> >It is quite optimal to use 'enum', 'std::bitset<32>' or just
>
> With <cstdint>::std::uint_least64_t one can do arithmetics
> and get the next state by just »++«.
Yes, that was my original point in start of this sub-thread.
In practice we rarely need to order states of set (nothing to
talk of finding next state of set). In practice we usually
need to insert, erase and count elements in it.
Inserting to integral variable used as set is done with '|='
erasing with '&=~' but efficient counting is tricky and I
bet that 'std::bitset' does it more efficiently than algorithm
of average Joe. ;)
==============================================================================
TOPIC: Return by reference
http://groups.google.com/group/comp.lang.c++/t/f6dd94c3223a1dbf?hl=en
==============================================================================
== 1 of 11 ==
Date: Sun, Feb 9 2014 3:50 am
From: Giuliano Bertoletti
Hello,
I've a classes like this:
class SubObject { ... };
class Object {
public:
SubObject sub;
};
class MyClass {
public:
Object obj;
public:
SubObject &GetSubObject() { return obj.sub; } // shortcut
};
which is the difference of calling?
==================
MyClass c;
SubObject &sub = c.GetSubObject();
SubObject sub = c.GetSubObject();
==================
It compiles both ways.
In practice I've an higher number of nested classes, so GetSubObject()
is actually a shortcut which digs deep into MyClass and retrieves the
item I need.
Giulio.
== 2 of 11 ==
Date: Sun, Feb 9 2014 4:04 am
From: Marcel Müller
On 09.02.14 12.50, Giuliano Bertoletti wrote:
> which is the difference of calling?
>
> ==================
> MyClass c;
>
> SubObject &sub = c.GetSubObject();
> SubObject sub = c.GetSubObject();
> ==================
The second line creates a copy of SubObject. It is in fact another
syntax for the following constructor call:
SubObject sub(GetSubObject());
This /might/ be expensive if copying SubObject is expensive. Furthermore
changes to sub do not apply to c.GetSubObject().
In general you should prefer references for non-trivial data types
unless you have good reasons not to do so.
Marcel
== 3 of 11 ==
Date: Sun, Feb 9 2014 4:07 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
Giuliano Bertoletti <gbe32241@libero.it> writes:
>I've a classes like this:
»classes« è un plurale, mentre l'articolo »a« si usa soltanto
con il singolare. Inoltre, credo che quando non c'è un altro
verbo, si preferisce »have« oppure »'ve got« invece di »'ve«,
perché il verbo »have« è accentato.
>SubObject &sub = c.GetSubObject();
>SubObject sub = c.GetSubObject();
In the first case, »sub« becomes just another name for the object
that already exists as a field of the class instance.
In the second case, a new object is created and the state (value)
of the object that already exists as a field of the class instance
is /copied/ to that new object.
(However, I rarely use reference results, so I am not totally sure.)
#include <iostream>
#include <ostream>
struct alpha
{ int beta = 7;
int & gamma()
{ ::std::cout << " gamma: " << &beta << ": " << beta << '\n';
return beta; }};
int main()
{ alpha a;
int & delta = a.gamma();
::std::cout << " delta: " << &delta << ": " << delta << "\n\n";
int epsilon = a.gamma();
::std::cout << "epsilon: " << &epsilon << ": " << epsilon << "\n\n"; }
== 4 of 11 ==
Date: Sun, Feb 9 2014 4:58 am
From: Jorgen Grahn
On Sun, 2014-02-09, Marcel Müller wrote:
> On 09.02.14 12.50, Giuliano Bertoletti wrote:
>> which is the difference of calling?
>>
>> ==================
>> MyClass c;
>>
>> SubObject &sub = c.GetSubObject();
>> SubObject sub = c.GetSubObject();
>> ==================
>
> The second line creates a copy of SubObject. It is in fact another
> syntax for the following constructor call:
>
> SubObject sub(GetSubObject());
>
> This /might/ be expensive if copying SubObject is expensive. Furthermore
> changes to sub do not apply to c.GetSubObject().
>
> In general you should prefer references for non-trivial data types
> unless you have good reasons not to do so.
Depends a lot on the circumstances. If it's clear that the lifetime
of 'SubObject& sub' is shorter than whatever it's referencing, then
sure. If not ... very bad things can happen if the object dies and he
uses that reference to it.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
== 5 of 11 ==
Date: Sun, Feb 9 2014 4:05 am
From: Luca Risolia
Jorgen Grahn wrote:
> Depends a lot on the circumstances. If it's clear that the lifetime
> of 'SubObject& sub' is shorter than whatever it's referencing, then
> sure. If not ... very bad things can happen if the object dies and he
> uses that reference to it.
class MyClass : public std::enable_shared_from_this<MyClass> {
public:
Object obj;
public:
std::shared_ptr<SubObject> GetSubObject() {
return std::shared_ptr<SubObject>(shared_from_this(), &obj.sub);
}
};
auto c = std::make_shared<MyClass>();
auto sub = c->GetSubObject(); // c.use_count() is 2
== 6 of 11 ==
Date: Sun, Feb 9 2014 5:07 am
From: Jorgen Grahn
On Sun, 2014-02-09, Giuliano Bertoletti wrote:
>
> Hello,
>
> I've a classes like this:
>
> class SubObject { ... };
>
> class Object {
> public:
> SubObject sub;
> };
>
> class MyClass {
> public:
> Object obj;
>
> public:
> SubObject &GetSubObject() { return obj.sub; } // shortcut
> };
>
> which is the difference of calling?
>
> ==================
> MyClass c;
>
> SubObject &sub = c.GetSubObject();
> SubObject sub = c.GetSubObject();
> ==================
>
> It compiles both ways.
>
> In practice I've an higher number of nested classes, so GetSubObject()
> is actually a shortcut which digs deep into MyClass and retrieves the
> item I need.
You might want to review that design to see if there is a smarter way
of doing it. You're saying you drill past three or more levels to get
that object, and that seems unusual. Perhaps your classes are too
much like dumb data containers, and you could change them to contain
more of the intelligence?
On the other hand, dumb data containers aren't always a bad idea ...
By the way, don't forget the third form:
const SubObject& sub = c.GetSubObject();
Here you're still at the mercy of whoever owns the object, but at
least you're promising not to modify it without informing the owner.
It's rather common to only need read access to something. This way
you can document it, and the code will IMO be significantly easier
to read.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
== 7 of 11 ==
Date: Sun, Feb 9 2014 4:21 am
From: Luca Risolia
Giuliano Bertoletti wrote:
> SubObject &sub = c.GetSubObject();
Don't return references to sub objects. To safely share (sub)objects in memory
use smart pointers.
> SubObject sub = c.GetSubObject();
This is a copy and is safe.
If you read the answer I have given in my other answer, you will probably see
the difference better.
== 8 of 11 ==
Date: Sun, Feb 9 2014 5:43 am
From: Giuliano Bertoletti
ok, thank you.
Is it then safe to call:
c.GetSubObject().SomeFunction()
and expect a straight invocation of the original subobject (not a copy)?
Giulio.
Il 09/02/2014 13.04, Marcel Müller ha scritto:
> On 09.02.14 12.50, Giuliano Bertoletti wrote:
>> which is the difference of calling?
>>
>> ==================
>> MyClass c;
>>
>> SubObject &sub = c.GetSubObject();
>> SubObject sub = c.GetSubObject();
>> ==================
>
> The second line creates a copy of SubObject. It is in fact another
> syntax for the following constructor call:
>
> SubObject sub(GetSubObject());
>
> This /might/ be expensive if copying SubObject is expensive. Furthermore
> changes to sub do not apply to c.GetSubObject().
>
> In general you should prefer references for non-trivial data types
> unless you have good reasons not to do so.
>
>
> Marcel
>
== 9 of 11 ==
Date: Sun, Feb 9 2014 11:15 am
From: David Harmon
On Sun, 09 Feb 2014 13:21:40 +0100 in comp.lang.c++, Luca Risolia
<luca.risolia@linux-projects.org> wrote,
>Don't return references to sub objects.
Correct.
In general, your subobjects should belong only to you.
https://en.wikipedia.org/wiki/Law_of_Demeter
http://www.ccs.neu.edu/home/lieber/LoD.html
https://duckduckgo.com/html/?q=law+of+demeter
== 10 of 11 ==
Date: Sun, Feb 9 2014 11:35 am
From: ram@zedat.fu-berlin.de (Stefan Ram)
David Harmon <source@netcom.com> writes:
>In general, your subobjects should belong only to you.
>https://en.wikipedia.org/wiki/Law_of_Demeter
Yeah, but this seems to be related more to the idea of
information hiding / encapsulation than to the LOD.
A class needs to protect its invariants. One can prove
theorems about a field, when one can be sure that only
the given element functions can access this field.
== 11 of 11 ==
Date: Mon, Feb 10 2014 4:35 am
From: Stuart
>>>On 02/09/14, Giuliano Bertoletti wrote:
>>> which is the difference of calling?
[snip]
>>> ==================
>>> MyClass c;
>>>
>>> SubObject &sub = c.GetSubObject();
>>> SubObject sub = c.GetSubObject();
On 09/02/2014, Marcel Müller wrote:
>> The second line creates a copy of SubObject.
[snip]
On 02/09/14, Giuliano Bertoletti wrote:> ok, thank you.
>
> Is it then safe to call:
>
> c.GetSubObject().SomeFunction()
>
> and expect a straight invocation of the original subobject (not a copy)?
That's right.
Note that such design is frowned upon by some people because it makes
the contract MyClass harder to grasp: Whoever gets access to the
instance of MyClass can also manipulate the sub-object at will. This way
it is not clear why the sub-object is a sub-object of MyClass and not
just an ordinary object that can be manipulated by both MyClass and
everybody else.
If you return a const reference (const SubObject&), however, it becomes
much clearer. The MyClass has full access to the sub-objects, but
clients of MyClass can no longer change MyClass's sub-object but only
retrieve information from it.
Regards,
Stuart
==============================================================================
TOPIC: Top 20 coding interview problems asked in Google with solutions:
Algorithmic Approach
http://groups.google.com/group/comp.lang.c++/t/f0866a8c45ecb553?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Feb 10 2014 11:34 am
From: lin.quan.20@gmail.com
http://www.amazon.com/coding-interview-problems-Google-solutions/dp/1495466574/
Must Have for Google Aspirants !!!
This book is written for helping people prepare for Google Coding Interview. It contains top 20 programming problems frequently asked @Google with detailed worked-out solutions both in pseudo-code and C++(and C++11).
Matching Nuts and Bolts Optimally
Searching two-dimensional sorted array
Lowest Common Ancestor(LCA) Problem
Max Sub-Array Problem
Compute Next Higher Number
2D Binary Search
String Edit Distance
Searching in Two Dimensional Sequence
Select Kth Smallest Element
Searching in Possibly Empty Two Dimensional Sequence
The Celebrity Problem
Switch and Bulb Problem
Interpolation Search
The Majority Problem
The Plateau Problem
Segment Problems
Efficient Permutation
The Non-Crooks Problem
Median Search Problem
Missing Integer Problem
==============================================================================
TOPIC: Cracking Programming Interviews: 500 Questions with Solutions
http://groups.google.com/group/comp.lang.c++/t/4532417d39af96b4?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Feb 10 2014 11:38 am
From: sergei.nakariakov.5@gmail.com
http://www.amazon.com/Cracking-Programming-Interviews-Questions-Solutions/dp/1495459802/
Part I Algorithms and Data Structures
1 Fundamentals
Approximating the square root of a number
Generating Permutation Efficiently
Unique 5-bit Sequences
Select Kth Smallest Element
The Non-Crooks Problem
Is this (almost) sorted?
Sorting an almost sorted list
The Longest Upsequence Problem
Fixed size generic array in C++
Seating Problem
Segment Problems
Exponentiation
Searching two-dimensional sorted array
Hamming Problem
Constant Time Range Query
Linear Time Sorting
Writing a Value as the Sum of Squares
The Celebrity Problem
Transport Problem
Find Length of the rope
Switch Bulb Problem
In, On or Out
The problem of the balanced seg
The problem of the most isolated villages
2 Arrays
The Plateau Problem
Searching in Two Dimensional Sequence
The Welfare Crook Problem
2D Array Rotation
A Queuing Problem in A Post Office
Interpolation Search
Robot Walk
Linear Time Sorting
Write as sum of consecutive positive numbers
Print 2D Array in Spiral Order
The Problem of the Circular Racecourse
Sparse Array Trick
Bulterman's Reshuffling Problem
Finding the majority
Mode of a Multiset
Circular Array
Find Median of two sorted arrays
Finding the missing integer
Finding the missing number with sorted columns
Re-arranging an array
Switch and Bulb Problem
Compute sum of sub-array
Find a number not sum of subsets of array
Kth Smallest Element in Two Sorted Arrays
Sort a sequence of sub-sequences
Find missing integer
Inplace Reversing
Find the number not occurring twice in an array
3 Trees
Lowest Common Ancestor(LCA) Problem
Spying Campaign
4 Dynamic Programming
Stage Coach Problem
Matrix Multiplication
TSP Problem
A Simple Path Problem
String Edit Distance
Music recognition
Max Sub-Array Problem
5 Graphs
Reliable distribution
Independent Set
Party Problem
6 Miscellaneous
Compute Next Higher Number
Searching in Possibly Empty Two Dimensional Sequence
Matching Nuts and Bolts Optimally
Random-number generation
Weighted Median
Compute a^n
Compute a^n revisited
Compute the product a × b
Compute the quotient and remainder
Compute GCD
Computed Constrained GCD
Alternative Euclid' Algorithm
Revisit Constrained GCD
Compute Square using only addition and subtraction
Factorization
Factorization Revisited
Decimal Representation
Reverse Decimal Representation
Solve Inequality
Solve Inequality Revisited
Print Decimal Representation
Decimal Period Length
Sequence Periodicity Problem
Compute Function
Emulate Division and Modulus Operations
Sorting Array of Strings : Linear Time
LRU data structure
Exchange Prefix and Suffix
7 Parallel Algorithms
Parallel Addition
Find Maximum
Parallel Prefix Problem
Finding Ranks in Linked Lists
Finding the k th Smallest Element
8 Low Level Algorithms
Manipulating Rightmost Bits
Counting 1-Bits
Counting the 1-bits in an Array
Computing Parity of a word
Counting Leading/Trailing 0's
Bit Reversal
Bit Shuffling
Integer Square Root
Newton's Method
Integer Exponentiation
LRU Algorithm
Shortest String of 1-Bits
Fibonacci words
Computation of Power of 2
Round to a known power of 2
Round to Next Power of 2
Efficient Multiplication by Constants
Bit-wise Rotation
Gray Code Conversion
Average of Integers without Overflow
Least/Most Significant 1 Bit
Next bit Permutation
Modulus Division
Part II C++
8 General
9 Constant Expression
10 Type Specifier
11 Namespaces
12 Misc
13 Classes
14 Templates
15 Standard Library
==============================================================================
TOPIC: Getting Started with a Visual Studio C++ 2013 IDE
http://groups.google.com/group/comp.lang.c++/t/6af661da9c3466bf?hl=en
==============================================================================
== 1 of 1 ==
Date: Tues, Feb 11 2014 4:00 am
From: malcolm.mclean5@btinternet.com
On Saturday, February 1, 2014 4:28:55 AM UTC, W. eWatson wrote:
> I understand C++. What I'm looking for is how one operates the IDE
> provided in VS C++ Desktop. What programming I've done usually does not
> include a sophisticated IDE.
>
I'm basically in the same situation.
I downloaded the latest version of Visual Studio Express for my new Windows 8.1
machine.
Start by creating an empty console project. Then create a C version of "hello world". Get that running, and it means that the compiler is basically set up.
Then try allowing it to make the skeleton for you, still in a console project.
You'll get lots of non-standard stuff, but nothing too awful. Write hello
world out in Unicode. (In Hebrew it's "shalom liolam", shin-lamed-vav-mem
space lamed-ayin-vav-lamed-mem, see if you can get it working in a non-Latin
script).
The try hello world in a window.
Gradually build up, getting more familiar with the IDE as you add complexity.
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en
To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment