codebuddy
BAN USER
- 28of 28 votes
AnswersYou are given a binary tree with the following node structure:
struct Node { int data; // some data struct Node *left, *right; // References to left and right children struct Node *previous, *next; // References to previous and next nodes };
The tree is initialized with previous = next = NULL for all the nodes.
- codebuddy
Using the previous and next pointers construct a doubly linked list such that each node's next is the node to its right at the same level and the last node's next is the first node at the next level.(similarly previous). The algorithm should have space complexity O(1). i.e., should be done without using extra data structures.You are given a binary tree with the following node structure| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm
I have an answer. Not sure if it is bug free
void treeList(struct Node * root)
{
struct Node *lastNode = root; // End of the imaginary Queue
struct Node *currentNode = root; // Start of the imaginary Queue
while(currentNode)
{
cout << currentNode->data << ' ';
if(currentNode->left)
{
lastNode->next = currentNode->left;
currentNode->left->previous = lastNode;
lastNode = currentNode->left;
}
if(currentNode->right)
{
lastNode->next = currentNode->right;
currentNode->right->previous = lastNode;
lastNode = currentNode->right;
}
currentNode = currentNode->next;
}
}
Repellabryan25416, Accountant at A9
Hello, I am a Managing editor. I have completed my studies from New York. Apart from this, whenever I am ...
RepAbigailFlores, AT&T Customer service email at A9
I have outstanding creative thinking skills that are helpful for overcoming issues in writing and for coming up with new ...
RepConnieLavender, Animator at Altera
My name is ConnieLavender . I am working as a Broker associate . I love field work and visiting different places to ...
Replelarolen76, Android test engineer at Alliance Global Servies
As a Public finance economist I am working at Liberal company . Here I will take a leadership role in the ...
RepPearlBenda, Associate at Accenture
I am Pearl , a Power Plant Operator with in-depth knowledge of all aspects of operation and maintenance and 9 years ...
Repmalloymirna65, Developer Advocate at 247quickbookshelp
I am Mirna Timekeeping clerks distribute and collect timesheets, timecards or work charts either as hard copies or electronically to ...
RepVictoriaMitchell, Animator at ABC TECH SUPPORT
I am an Analysis Manager.I have 7 years of experience in leveraging data analysis to develop. And I love ...
RepCallaRita, techsupport at Knowledge Systems
Hi, I am an Administrative person . It is to develop and sustain an early childhood organisation. I was a teacher ...
RepGirikScott, Android Engineer at ABC TECH SUPPORT
I write stories of families based on the unique experience that early settlers faced in this country. I have a ...
Repsophiaddelano, Android Engineer at 247quickbookshelp
Extensive experience setting up, installing, and maintaining a variety of audio equipment. I Work with loudspeakers, amplifiers,microphones, and more ...
RepNancyNieves, Accountant at ABC TECH SUPPORT
Hey I am a HR Trainer. I have been working in this field for almost 3 years. I am very ...
RepKatieKate, Developer at Amazon
Katie , a general laborer skilled in construction work, landscaping and trimming, and other commercial and residential tasks. Love to find ...
Repdawnmhodges111, abc at 247quickbookshelp
Hello I am a Web writer. All my studies complete from california.my hobby is write different type article.Right ...
Repjennykyiler, Area Sales Manager at AMD
Jenny , an Assistant Secretary with a track record of employer satisfaction in performing various administrative tasks, and completing visual presentations ...
Replegabesg, Android Engineer at ASU
My name is JoeColeman . I am working at Rite Solution as a Data entry keyer . It's been almost 10 ...
RepDavidJohaan, Digital marketing Experinced at Abs india pvt. ltd.
I am David , a scanner operator for seven years in the industry Paearb. Six months ago , I’d an injury ...
Repdalecronin028, Animator at Pinterest
Hello, I am Dale. I am a Tourist guide who welcomes tourists . Tourist Guides act as ambassadors of the country ...
RepJeniferWatts, SEO at Accolite software
I’m Jenifer , working as a press reporter in the USA. I collect, write, or distribute news or other current ...
Replarrymeisterl71, Analyst at ABC TECH SUPPORT
Working as Food cooking machine tender at Adray it's almost 10 years . Here I Operate or tend cooking equipment ...
RepCandiRoy, HR at ASU
I am a qualified CEO with experience in overseeing the daily activities of small businesses and large corporations alike. I ...
RepJohnHentz, Animator at Abs india pvt. ltd.
JohnHentz is a Responsible Financial planner working at Plan Smart Partner . i Analyze clients' financial statuses income, expenses and liabilities ...
RepMinnieRuffin, Accountant at Boomerang Commerce
Minnie , a business leader professional accustomed to managing projects with Vashikaran Specialist in nagpur pay after results with fast-paced and ...
RepLaylaLee, abc at AMD
Creative and dedicated photo editor with experience in photojournalism and marketing material development. I like to explore Best tantrik in ...
RepLiamLee, abc at ADP
Proven leadership skills that have helped projects get completed within the time and budget constraints, Dedication to following appropriate safety ...
Repdubinalinda4, Animator at Apache Design
Hello, I am a school librarian from Lewistown USA. I work in public or private schools at elementary, middle and ...
Repnasliebaker, Solutions Engineer at Edinprotechnologies
Je suis Naslie , un chercheur interdisciplinaire et collaboratif axé sur l'amélioration de la santé humaine et le mentorat de ...
RepDaisyRoss, Video game designer at A9
Seeking lead game programmer and position to utilize knowledge and skills to advance portfolio and potential for increased responsibility. Explore ...
RepShaneFord, Associate at ABC TECH SUPPORT
ShaneFord , Uniformed police officer working at Kash n' Karry here i Assists in the investigation of crimes and/or suspected ...
RepEthelRector, Animator at AMD
EthelRector is a clerk working at Egghead Software with lots of experience . exploring new things Black magic to break up ...
RepNiaNorna, Analyst at ADP
I am an established career journalist with 15 years of writing and copy editing experience in the newsroom. Seeking to ...
Repeleanormzavala63, Android Engineer at 247quickbookshelp
Hello I am a publicity agent, I have completed all my studies from Brighton. And now-a-days I am working as ...
Repkentyoung319, Applications Developer at ABC TECH SUPPORT
I am KentYoung . I am working as an Orthotics technician at The Wiz . As an orthotic technician,I manufacture orthotic ...
RepTashaGarlo, Blockchain Developer at ASAPInfosystemsPvtLtd
I’m Tasha , working as a press reporter in the USA. I collect, write, or distribute news or other current ...
RepManilaRoche, Animator at Abs india pvt. ltd.
Manila , an extensive executive assistant with experience of 4 years in the field of administrative functions, managing the office of ...
Repshinchunigo, Benefits clerk at Good Times
Votaw, Top Duties and Qualifications Benefits clerk . It is responsible for performing administrative tasks to support daily business operations. My ...
Repmeerjahelesan, Backend Developer at Abs india pvt. ltd.
My name is FredHolli. I am working at Warner Brothers Studio Store as a Human resources clerk .I mostly spend ...
RepRebecaGomes, Amazon Customer Service Number +1-808.800.0449 at ABC TECH SUPPORT
A printmaker designs and creates prints using techniques such as woodcuts or silkscreen, which are usually transferred to surfaces using ...
Replimachiya788, Associate at ABC TECH SUPPORT
LeviWebber , is a Housekeeping cleaner at Exact Solutions . I am also exploring new things . Mayong Assam tantrik contact number . Housekeepers ...
Repmaryctedesco7485, Accountant at ABC TECH SUPPORT
Efficient Production Manager with 15 years of experience leading diverse manufacturing teams to create high-quality products at top speeds. Dedicated ...
RepJessicaMoss, Member Technical Staff at Bloomberg LP
Jessica , a technical writer with 5+ years of experience writing high-quality internal and user-facing support. As I love to write ...
RepYaniraBryant, Accountant at CGI-AMS
I am Yanira , a writer by fate. Went from writing for media outlets to exploring the world of content creation ...
RepIvyWeir, HTML Freshers at Clean Power Research
Ivy , an Empathetic and passionate Psychology student with experience in performing psychological patient assessments, assisting in psychotherapy, monitoring patients' progress ...
RepDavlinaSmith, abc at ADP
I am a current residential landlord with 5 years’ experience looking to expand into commercial property management.Former florist by ...
Replaurabaumgaert876, Animator at 247quickbookshelp
I have Six years of experience facilitating cutting-edge solutions with a wide range of Computer software engineer and technology skills ...
Repdodramee56, Associate at Absolute Softech Ltd
As a Lift truck operator at Fayva for almost ten years I am working here . Here I met different people ...
RepBonnieToney, abc at A9
I am a highly dedicated and accomplished asset manager with an exceptional work ethic and customer service record. I adapt ...
RepTerryMorales, Accountant at ADP
I assist other social and human service providers in providing client services in a wide variety of fields, such as ...
RepRilynFreeman, Area Sales Manager at Knewton
Hi my name is Rilyn. Library assistant in Jeans Unlimited company. I help to keep libraries organised and efficient while ...
RepEllaJoni, abc at 8x8
By profession I am an auditing assistant with extensive experience in handling administrative duties and executive responsibilities associated with both ...
RepNaomiSmith, Integration Software Engineer at ASU
Naomi , a strategic Merchandise Buyer with over 4 years of professional experience in merchandise planning and purchasing positions. Advanced presentation ...
RepEsotaTaylor, abc at 8x8
I am working as a lecturer with exceptional teaching abilities seeking employment in your organization. I have excellent experience in ...
RepJenniaLopez, Associate at Absolute Softech Ltd
Jennia , a hard-working Packer with a strong determination to finish all assignments in a timely manner. Replaces , operates and maintains ...
Repminniermontano, Android test engineer at 8x8
Hello my name is Minnie and i live in california. And I'm working as a paymaster at Tech Hifi ...
RepSammyTurner, HR Executive freshers at Abs india pvt. ltd.
Sammy , an experienced mortuary service provider performed a variety of tasks involved in holding appropriate and solemn rites during funeral ...
Repswammesha, Blockchain Developer at ADP
As a machine operator at Star Bright Investment Group it's been almost 10 years . here i learn different things ...
RepWilliamWiltz, Call Girls in Chawri Bazar at Amdocs
Hi , I am William, a Medical technologist with extensive knowledge around sample examination and analyzing results. Selected from a pool ...
Reppetersmith36788, Animator at ABC TECH SUPPORT
I am working at Eden Lawn Service as a Bridge and lock tender . Here I manage all the things like ...
Repmirezwanda, Android test engineer at Arista Networks
Computer database administrator with 3+ years of experience working in Gamma Realty . I often plan security measures, making sure that ...
Replesamean618, Android Engineer at Adap.tv
Working as a Choreographer it's almost 10 years at Happy Bear Investment . Here I am dealing with different people ...
Repbrianlwarren596, Android Engineer at 247quickbookshelp
Hey my name is BrainWarren and I am working as an Interpreter.my main work is Interpreters and translators convert ...
RepAileen Kate, HR Executive Trainee at Bankbazaar
Aileen , a game designer with 4+ years of experience in a creative yet deadline-driven environment. Eager to join The Rock ...
RepSidneyWarren, Development Support Engineer at Abs india pvt. ltd.
Sidney , Materials Planner adept at analyzing the usage of production materials, managing inventories, coordinating new personnel vashikaran specialist contact number ...
RepJamieWilliams, Android Engineer at Email Customer Service
My name is Jamie.and i am a Translator It's been almost 2 years since I worked in this ...
RepAriAllen, AT&T Customer service email at ABC TECH SUPPORT
I have experience with collecting data and conducting experiments for studies in a variety of industries. I am a respected ...
Repsuegdiaz765, Android test engineer at 247quickbookshelp
My name is Sue and I am a Specialist. We Specialist employees are responsible for specific tasks or activities in ...
RepAnaCardenas, Android Engineer at Allegient
Working as a Window clerk at EnviroSource Design for almost 10 years . Here I help people to guide . End a ...
RepHaleyTorres, abc at A9
I am an enterprising Corporate Accountant proficient in generally accepted accounting principles including use of the latest industry standard software ...
RepSerenaWilliams, Android test engineer at ASAPInfosystemsPvtLtd
Serena , a Building Consultant engages myself in ongoing communication with clients until the project is completed and collects necessary data ...
RepBriannaWright, Analyst at A9
I am a skilled project manager with years of exemplary service in diverse IT roles. I am passionate about utilizing ...
Repcolleenpbeverly02, Android test engineer at ABC TECH SUPPORT
Hello I am Colleen Dedicated and hardworking Geographic information specialist analyst with 15 years of experience working with ArcGIS software ...
Repsushiswla65, Area Sales Manager at ABC TECH SUPPORT
My name is SarahProctor . I am working as a Video editor at Konsili . I am exploring some magical tricks . vashikaran ...
RepElizabethMaxim, Android test engineer at AMD
A financial economist is responsible for the production and distribution of goods and services. We are also responsible for collecting ...
RepBertMusi, Consultant at Accenture
I am a service technician working at Parade of Shoes . It's been almost 5 years since I have been ...
Repopalphelan234, Associate at 247quickbookshelp
I am a specialized Cardiac and vascular nurse at the Circus World . Here I meet different people and observe their ...
Replinhhonibh, Animator at ABC TECH SUPPORT
I am an experienced, officially certified driving instructor. Excellent driver with a great safety record. Encyclopedic knowledge of traffic rules ...
RepAmyuDiaz, abc at 8x8
Professional cost accountant with several years of experience in accounting tasks such as maintaining inventory, calculating liability, budgeting labor costs ...
RepEileenWenda, DIGITAL MARKETING at Accenture
I am Eileen , a football Referee skilled at maintaining a safe environment for both players and observers, inspecting the playing ...
RepLucindaBriella, Accountant at Clean Power Research
Lucinda, I conduct the admissions process and promote school to prospective students and their guardians. I need a spell caster ...
RepMargySpencer, Area Sales Manager at ABC TECH SUPPORT
Hey my name is Margy and i am a scientific photographer. I have full experience of 5 years of work ...
RepCathyCruz, Analyst at AMD
I am a highly responsible service station manager seeking an opportunity to work in a top company oy aid in ...
RepBravoDwayne, Blockchain Developer at ADP
Bravo , a Broker Assistant skilled at assisting financial advisors and stockbrokers in any tasks as required. As I love to ...
- codebuddy November 26, 2010