Does PHP & XML work together in the same place ? LoL , Yes, they do !

PHP and XML


XML stands for Extensible Markup Language. A markup language is used to annotate text or add additional information. These annotations are not shown to the end-user, but are needed by the ‘machine’ to read and subsequently process the text correctly.An XML document is plain text and contains tags delimited by < and >.
XML plays a significant role in the present world of web development, it is perfectly useful for those who wish to make use of web technologies for distributing information across the web.
XML is used to format a document with a web browser. It is an influential and effectual tool to process a document’s contents and therefore, creating own tags is possible with XML. It works well with any operating system and maintains a great amount of flexibility, which is very essential for the web development scenario. 

Parsing an XML Document

Parsing is usually applies to text  it is  the act of reading text and converting it into a more useful in-memory format, “understanding” what it means to some extent.
An XML Parser is a parser that is designed to read XML and create a way for programs to use XML.

PHP – Simple XML

PHP 5’s new SimpleXML module makes parsing an XML document, well, simple. It turns an XML document into an object that provides structured access to the XML.
The simple XML parser is used to parse Name, attributes and textual content.
The simple XML functions are shown below:


simplexml_load_file():

This function accepts file path as a first parameter and it is mandatory:
simplexml_load_file(($fileName,$class,$options,$ns,$is_prefix)

simplexml_load_string():

This function accepts the string instead of file reference.
simplexml_load_string($XMLData,$class,$options,$ns,$is_prefix)

simplexml_import_dom():

This function accepts DOM formatted XML content and it converts into simple XML.
simplexml_load_string($DOMNode,$class)
Assuming we’ve got our XML file above saved as a file called sctpl.xml in the same folder as our php file, we can read the whole feed into an object with the following code.

<?php
$sctpl = consultancy('sctpl.xml');
?>


PHP – Simple XML GET:

Get Node Values:

Consider following XML file:
sctpl.xml:
<SCTPL>

<Location >
<address>4/B wing,Trishul Apartments,Sindhi Society Rd Number1,Chembur, Mumbai.
</address>
<phno> 022-25277413 </phno>
<facebook>https://www.facebook.com/suvenconsultants/</facebook>
<youtube>https://www.youtube.com/user/rockyjagtiani</youtube>
<Location>

</SCTPL>

Following Code will return value of address,phno,facebook,youtube nodes:

Example

<?php
$xml=simplexml_load_file(“sctpl.xml”) or die(“Error: Cannot create object”);
echo $xml->Address . “<br>”;
echo $xml->phno . “<br>”;
echo $xml->facebook . “<br>”;
echo $xml->youtube; ?>
Output of above code will be:
4/B wing,Trishul Apartments,Sindhi Society Rd Number 1,Chembur, Mumbai 

022-25277413

https://www.facebook.com/suvenconsultants/

https://www.youtube.com/user/rockyjagtiani


Get Node Values of Specific Elements

Consider another XML file:

SuvenConsultancy.xml:
<SCTPL>

<Location name=”Chembur”>
<address>4/B wing,Trishul Apartments,Sindhi Society Rd Number1,Chembur, Mumbai.
</address>
<phno> 022-25277413 </phno>
<facebook>https://www.facebook.com/suvenconsultants/</facebook>
<youtube>https://www.youtube.com/user/rockyjagtiani</youtube>
<Location>

<Location name=”Kandivali”>
<address>510, 5th Floor , Ghanshyam Enclave,Link Road, Lalji-pada JunctionKandivali West, Mumbai
</address>
<phno> 022-28674177</phno>
<facebook>https://www.facebook.com/suvenconsultants/</facebook>
<youtube>https://www.youtube.com/user/rockyjagtiani</youtube>
<Location>

</SCTPL>
The following example gets the node value of the <phno> element in the first and second <location>elements in the “SuvenConsultancy.xml” file: 

Example

<?php
$xml=simplexml_load_file(“SuvenConsultancy.XML”or die(“Error: Cannot create object”);
echo $xml->location[0]->phno“<br>”;
echo $xml->location[1]->phno;
?>
The output of the code above will be:
022-25277413
022-28674177

Get Attribute Values:

The following example gets the attribute value of the “name” attribute of the first <location> element:

Example

<?php
$xml=simplexml_load_file(“SuvenConsultancy.xml”or die(“Error: Cannot create object”);
echo $xml->location[0][‘name’];
?>
The output of the code above will be:
Chembur

Want to learn Web Technologies?

Is a Twitter Purge of the Alt-Right Underway?

The site just banned a prominent white supremacist, who could be the first of many.

Finally bowing to public pressure, Twitter is enforcing a series of rules Monday that will potentially suspend accounts affiliated with hate groups, and lead to a long overdue crackdown on the so-called alt right, Recode reported on Sunday. 

The rules were initially announced in November but are only now going into effect. According to Recode, “Twitter will also start penalizing accounts that include ‘hateful imagery and display names,’ presumably including Nazi insignia, or those who ‘use [a] username, display name, or profile bio to engage in abusive behavior.'”

Hate groups have exploited Twitter’s incredibly lax oversight to harrass Jewish journalists; organize the Charlottesville Neo-Nazi rally, which killed Heather Heyer and injuried countless others; and help propagate Pizzagate, which led to a shooting in a DC pizza place, among other offenses.

Users have complained for nearly two years that the company has squandered its considerable resouces on cosmetic changes and expanded character limits, all the while providing a platform for racism and violence online and off. Most critically, Twitter said that in addition to banning accounts, it “would be monitoring groups’ behavior outside of the website, as it makes its decision as to which users have run afoul of its new guidelines.”

Twitter’s new policy also states that, “You also may not affiliate with organizations that — whether by their own statements or activity both on and off the platform — use or promote violence against civilians to further their causes.” 

Not ones to go quietly, many of the hate groups are already shifting to another social media platform, Gab, which has proven friendlier to white nationalists.

The purge began Monday morning. As Will Somner, Campaign Editor at the Hill and alt-right expert is documenting on his Twitter feed, so far Jared Taylor and his American Renaissance site were off as of 10am EST. 

Follow Sommer for more updates on Twitter’s progress.

 

Related Stories

  • What Is The Alt-Right ‘White Sharia’ Movement?
  • Richard Spencer’s Former Classmate Confirms He’s Always Been a Monster
  • Richard Spencer’s Former Classmate Dishes on Pure Hell of Knowing Him

8 Legitimate Grounds for Congress to Initiate Impeachment Proceedings Against Trump

Widespread corruption, abuse of power and a threat to our republic.

As we demonstrate in a new paper, The Legal Case for a Congressional Investigation on Whether to Impeach President Donald J. Trump, based on publicly reported information, as of today there are at least eight grounds for the House of Representatives to authorize the Judiciary Committee to begin hearings on whether to impeach President Donald J. Trump.

This paper presents a legal analysis based on the text, structure and history of the Constitution and federal law, and legal and political precedent, that we have developed in consultation with a wide range of experts over the past ten months. Some of the grounds for investigation are based on violations of specific enumerated constitutional or statutory provisions, but in keeping with the intent of the Founders and the 200-year history of impeachments, other grounds are based on abuses of power that do not fall easily within a specific proscription.

Here are the grounds for investigation.

1. Obstructing justice.

Beginning soon after the inauguration, the president engaged in a course of conduct that sought to obstruct justice in the Federal Bureau of Investigation’s investigations of Lieutenant General Michael Flynn and of his own campaign’s potential involvement with Russian activity in the 2016 election.

2. Violating the Foreign Emoluments Clause and Domestic Emoluments Clause of the U.S. Constitution.

Through his businesses in the United States and abroad, the president receives payments, regulatory approval, and other forms of direct and indirect financial benefits from foreign governments. These violate the Constitution’s Foreign Emoluments Clause, which prohibits federal officials, including the president, from receiving a “present” or “emolument” from any foreign government or official. The president’s businesses also act as a conduit for enrichment from federal and state government coffers. These violate the Domestic Emoluments Clause, which prohibits the president from receiving, beyond his official salary, any emolument from the United States or any state.

3. Conspiring with others to commit crimes against the United States involving the solicitation and intended receipt by his presidential campaign of things of value from a foreign government and other foreign nationals, and to conceal those violations.

In the 2016 election, the senior officials of Trump’s presidential campaign (including his campaign chairman, his son and his son-in-law) met with Russian nationals after an invitation to receive compromising information about his campaign opponent, Hillary Clinton, that they were told would be of great value to the campaign. Federal campaign finance law prohibits a candidate or campaign from soliciting a foreign national (including a foreign government) for a thing of value. In 2017, after this meeting was revealed, President Trump personally dictated a misleading public statement on behalf of his son about the intended purpose of the meeting.

4. Advocating illegal violence, giving aid and comfort to white supremacists and neo-Nazis, and undermining constitutional protections of equal protection under the law.

Over the course of 2017, the president has made a series of public statements that together, constitute a pattern of conduct violating his constitutional obligation to “take care that the laws be faithfully executed,” protect the citizenry against “domestic violence,” and ensure “the equal protection of the laws.”

5. Abusing the pardon power.

The president’s pardon of former Arizona sheriff Joseph Arpaio, who had been convicted of criminal contempt of court for willfully violating a court order to stop violating the constitutional rights of Latino drivers, abused the pardon power by sending the dangerous message that similarly inclined unscrupulous law enforcement officials could not only violate individual rights, but could violate court orders requiring them to stop violating those rights with impunity because the president would support them.

6. Threatening nuclear war against foreign nations, undermining and subverting the essential diplomatic functions and authority of federal agencies, including the Department of State, and engaging in other conduct that grossly and wantonly endangers the peace and security of the United States, its people and people of other nations, by heightening the risk of hostilities involving weapons of mass destruction, with reckless disregard for the risk of death and grievous bodily harm.

Through a series of public statements (including on Twitter), and beginning particularly in the late summer of 2017, the president has made increasingly reckless public threats against North Korea. It is not clear whether President Trump understands the ramifications of his actions. While the president is the commander-in-chief of the armed forces, reckless or wanton conduct with the potential for millions of deaths constitutes an abuse of power.

7. Directing or endeavoring to direct law enforcement, including the Department of Justice and the Federal Bureau of Investigation, to investigate and prosecute political adversaries and others, for improper purposes not justified by any lawful function of his office, thereby eroding the rule of law, undermining the independence of law enforcement from politics, and compromising the constitutional right to due process of law.

The president has repeatedly pressured federal law enforcement to investigate and prosecute political adversaries, including former campaign opponent Hillary Clinton and the Democratic Party. The president’s attempts to employ the criminal investigative powers of the federal government against political opponents for purposes unrelated to national security, the enforcement of laws, or any other lawful function of his office are grounds for impeachment.

8. Undermining the freedom of the press.

The president has repeatedly attacked major U.S. news organizations as “fake news” and the “enemy of the American people.” The president is certainly free to criticize particular news stories he believes are inaccurate, and no one tweet in isolation constitutes an impeachable offense. But his consistent pattern of attacks undermines a critical foundation of a free society.

Purpose of Impeachment

Some of the impeachable offenses discussed in the paper overlap with the criminal investigation of special counsel Robert Mueller; some overlap with other pending federal litigation; others do not overlap with any parallel proceeding. However, as our paper explains, an impeachment investigation is entirely separate from a criminal or other judicial proceeding. The purpose of impeachment is not to punish for past crimes, but to remove from office a dangerous official who threatens the rule of law and the republic itself.

Congress must not use the Mueller investigation or other litigation as an excuse to shirk its duty to conduct its own independent impeachment hearings. The abuse of power, the corruption and the threat to our republic are here now.

 

Related Stories

  • Alabama Stunner: Democrat Doug Jones Defeats Right-Wing Extremist Roy Moore in Photo Finish U.S. Senate Race
  • Alabama Supreme Court Blocks Digital Ballot Preservation in Eleventh Hour
  • Alabama Supreme Court Blocks Digital Ballot Preservation Requirement to Verify the Vote in Tuesday’s Senate Election

If We Don’t Address Poverty, We Are Going to Lose Our Country

If we are to save the soul of this country from the poverty that is killing us, we must act, we must agitate, we must cause some righteous trouble.

In March of 1968, as part of a tour of US cities to shine a light on poverty and drum up support for the recently-launched Poor People’s Campaign, the Rev Dr Martin Luther King Jr visited the northwest Mississippi town of Marks. He saw a teacher feeding schoolchildren a meager lunch of a slice of apple and crackers, and started crying.

Earlier this month, officials from the United Nations embarked on a similar trip across the US, and what they observed was a crisis of systemic poverty that Dr King would have recognized 50 years ago: diseases like hookworm, caused by open sewage, in Butler County, Alabama, and breathtaking levels of homelessness in Los Angeles’ Skid Row, home to 55,000 people.

“I think it’s very uncommon in the first world,” UN special rapporteur Philip Alston said. “This is not a sight that one normally sees. I’d have to say that I haven’t seen this.”

The morally troubling conditions Dr King witnessed across the country cemented his call, along with leaders in the labor movement, tenant unions, farm workers, Native American elders and grassroots organizers, for a campaign to foster a revolution of values in America.

Half a century later, the conditions that motivated the 1968 Poor People’s Campaign have only worsened, making the need for a new moral movement more urgent than ever. Compared to 1968, 60% more Americans are living below the official poverty line today – a total of 41 million people. The gap between our government’s discretionary spending on the military versus anti-poverty programs has grown from two-to-one at the height of the Vietnam war to four-to-one today.

That’s why, this month, poor and disenfranchised people along with clergy and moral leaders nationwide launched the Poor People’s Campaign: a National Call for Moral Revival, to challenge the enmeshed evils of systemic racism, poverty, the war economy, ecological devastation, and our distorted national morality.

The observations by the United Nations published this week are an urgent alarm bell for the moral emergency facing the country. As King did 50 years ago and Alston did earlier this month, we will travel the country to make sure the poor are not ignored. But it is not enough to bear witness. If we are to save the soul of this country from the poverty that is killing us, we must act, we must agitate, we must cause some righteous trouble.

The Poor People’s Campaign: A National Call for Moral Revival, which will be highlighted by 40 days of direct action and nonviolent civil disobedience this spring, is not a commemoration. It’s an acknowledgment that, 50 years later, there is still so much work to do to foster a revolution of values in America.

There’s a strange irony in America when it comes to poverty. The states with the highest poverty rates are in the south. And those same states have the highest rates of voter suppression of black people. Through this racialized voter suppression, politicians who support policies that hurt the poor get elected. While a larger percentage of black people are living in poverty, in raw numbers, there are actually more white than black people below the poverty line.

So-called white evangelicals are omnipresent in the poorest areas of our country, and they say the least about systemic poverty, which is the foremost issue in authentic Christian religious theology. After our denominations splintered over the moral question of slavery and the nation stood on the brink of civil war, Frederick Douglas said“Between the christianity of this land and the christianity of Christ, I recognize the widest possible difference.”

Sadly, his observations ring true today.

These so-called evangelicals should listen to Pope Francis, who called poverty a “scandal.” He said, “In a world where there is so much wealth, so many resources to feed everyone, it is unfathomable that there are so many hungry children, that there are so many children without an education, so many poor persons. Poverty today is a cry. We all have to think if we can become a little poorer, all of us have to do this. How can I become a little poorer in order to be more like Jesus, who was the poor Teacher?”

The most radical, progressive shifts in our country’s history occurred when concerned citizens across racial lines come together. This was the case after the civil war, during the civil rights movement and today, in the Moral Mondays Movement and the Fight for $15.

The Poor People’s Campaign: A National Call for Moral Revival will unite Americans across all races, creeds, religions, classes and other divides – because it’s going to take all of us to revive the soul of our nation.

 

 

Related Stories

  • Incentive for Terrorism: America Has Taken Nearly 70% of the World’s Wealth Gains Since 2012
  • ‘All Eyes on U.S.’ as Honduran Election Panel Declares Incumbent President Hernández Election Winner
  • New Wall Street Journal Report Might Totally Destroy Republicans’ Favorite Anti-FBI Talking Point

The latest Samsung foldable smartphone patent makes it look like a sleek Nintendo 3DS

With the Galaxy S9 rumor mill continuing to pick up steam, one smartphone that continues to be shrouded in mystery is Samsung‘s foldable smartphone, believed to be called the Galaxy X. That mystery has been peeled back little by little, but a recent Samsung patent continues to show us what the device looks like and what it can do.

Originally uncovered by Dutch site LetsGoDigital, the patent, which was registered with the World Intellectual Property Organization (WIPO), shows a device that looks like a significantly thinner Axon M. Similar to ZTE’s offering, Samsung’s smartphone features a hinge that connects the two screens, though the hinge also allows the phone to be closed.

Unlike the Axon M, which keeps the screens exposed, Samsung’s attempt protects the screens when closed. Interestingly, the smartphone looks to include a sensor that calculates the angle between the first and second screen. This allows the phone to know when the second screen is not in use, with the display turning off to save battery life.

Elsewhere, the patent shows the phone’s two displays each featuring a camera and speaker, though it’s possible that there is a third camera and speaker on the rear. Also possible is the inclusion of a stylus, which would make sense for those keen on drawing on a larger canvas than what is afforded on the Galaxy Note 8.

Finally, the patent shows off gaming controls on one screen while gameplay runs on the other screen, à la a no-button take on the Nintendo 3DS. The implementation of such a feature will depend on how developers take to it, and there is reason to be skeptical about that — it’s not like they flocked to the Axon M, did they? I doubt this phone will sell like gangbusters, which will turn away the bigger developers, though I’m sure a handful might still give it a try.

Editor’s Pick

Much like the last time we caught wind of the supposedly-called Galaxy X, today’s news did not reveal when it might be announced. The earliest Samsung might mention the phone is during CES 2018, which is right around the corner. Whenever it is announced, we expect it to live alongside the Galaxy S9.

Would you be interested in picking up the Galaxy X? Let us know in the comments below.

Player agency

I labeled this post Dungeons & Dragons, but actually the issue of player agency is as true for computer games as it is for pen & paper role-playing games. Every game in which a player controls a character and a DM or a computer controls the world around that character has the same problem: How do we make the player believe that he is playing the hero who is driving the story forward, while the world around him reacts to his actions? How do we prevent the player from thinking that the game is scripted, on rails, and that it is the DM or computer who acts by throwing obstacles in the way of the character, and the character who is limited to reacting to those events?

The problem is most often presented as a difference between a linear story game and a sandbox game. However that is a false dichotomy. There are a lot of sandbox games in which player choice is an illusion, or where the player has the choice between irrelevant options like where to go, while the actually relevant events are scripted. On the other side a game that tells a story can actually have branches in the story and provide quite a lot of meaningful choices and decisions.

I recently had a problem with lack of player agency in a D&D game in which I am a player. The adventure is a WotC published one, Out of the Abyss. And because sandbox gaming is so popular, many of the WotC published adventures are presented in sandbox format. You have chapters after chapters describing locations and NPCs, but there is no written storyline. The idea is for the DM and the players to create the story together, but it is clear how that is somewhat illusory: One way or another the players end up going through the various locations presented. From one group to another the details and order of the encounters might change, but at the end of the day different groups playing through the same sandbox adventure will have similar experiences. In this particular case the DM didn’t have a lot of time to prepare, and thus ended up trying to present the encounters on the fly as we played. And somewhere in the process the story got lost, and we were just stumbling through the Underdark, getting hit by one unpleasant encounter after the other, while not knowing what actually our goal was or how to achieve it. So we really were in the situation of the world acting upon us, and us simply reacting. And with things not always going well, and the DM being fond of a gruesome narrative style of dark fantasy, at the end I felt more like a victim than like a hero.

Now the challenge for me is to run the D&D campaigns in which I am the DM in a way that this doesn’t happen. I do want the players to be the agents of the story, it should be them who drive the story forward and make the choices. However although both campaigns are presented as sandboxes, a lot of events that will happen are rather predictable. There are a lot of dungeons with rooms that contain monsters which aren’t likely to be open to negotiation. Open door, kill monster, loot treasure is the most likely sequence of events. It is hard to imagine Dungeons & Dragons without the dungeons that make up half of the name, but dungeons by their very nature aren’t all that much “sandbox”. They might not be linear, but the walls generally limit where adventurers can go. So dungeons are easily perceived as being “on rails”.

On the positive side players tend to enjoy a good dungeon romp more than they enjoy being in the middle of a sandbox without a goal. Too much guidance by a DM can be a problem, but not enough guidance can be a far more serious problem. Even in an old school hex crawl it is better if the players know towards what destination they are heading, and why.

Uses and abuses of challenge

Once upon a time, in a past so long a go that few people remember it, computer games came with an options menu in which you could choose the difficulty and challenge of the game yourself. The idea was that all of us would like games to be both winnable and not a pushover, but because preferences on how easily winnable a game should be, as well as experience and skill in a game, vary from user to user, it would be best to have several options in order to please everybody. Now that was way back when games still came in a box. With games increasingly switching to a “game as a service” online experience, difficulty settings fell out of favor. Somehow it appeared to make more sense if the same orc in World of Warcraft held the same challenge for each player, with the only variable being the power level of the player himself. With less and less single-player games around, and PvE games being more and more replaced by PvP, difficulty setting have become increasingly rare.

I’ve been playing a bunch of pseudo-PvP games on my iPad lately. Pseudo because I don’t necessarily fight another player online at the same time, but my army fights his computer-controlled army. That usually was nice enough at the start of the game. But then with each win I gained some sort of trophies or ranking, so that later I was matched against more and more powerful players. Ultimately it was obvious that this was a no-win proposition: The better I did, the more likely it became that I would lose the next game. The only strategy that worked was to deliberately lose games, to drop down in rankings, to then win the now easier PvP games in order to achieve the quests and goals the game set me. But that sort of cheesy strategy isn’t exactly fun.

The other type of game I played recently is the one in which your performance doesn’t actually matter at all any more. I played Total War: Arena, but many team vs. team multiplayer games fall into the same category: The contribution of any single player to the outcome of a 10 vs. 10 battle is only 5%. That gets quite annoying if you come up with a brilliant move and outmaneuver another player and crush him, only to find that the 9 other players on the enemy team obliterated your 9 team mates, and you lost the battle. Especially since in Total War: Arena you end up with more rewards having done nothing much in a won battle than for a great performance in a lost battle.

Finally my wife was complaining about a problem with challenge levels in her iPad puzzle games: The games are free to play, they get harder and harder with each level until you can’t beat it any more, and then the game offers you a way out: Use some sort of booster, which of course you need to pay real money for, to make the too hard levels easy enough to win again.

Somehow I get the feeling we lost something important when difficulty sliders went out of fashion. However the discussion of difficulty and challenge is complicated by the fact that this is one of the issues where gamers are the most dishonest about. Gamers tend to say they want more challenge, but when you observe what they are doing, e.g. attacking the enemy castle in a PvP MMORPG at 3 am in the morning, it is clearly that they are mostly occupied with avoiding or circumventing any actual challenge. Pay2Win and loot boxes wouldn’t be such an issue if gamers weren’t actually spending their money on improving their chances to win. If most gamers were so interested in challenge, then why is there so much cheating and botting going on? People want to win, by any means, and by talking up the challenge they want to make their win look more impressive. Which is kind of sad, if you think about it, that their positive self-image depends on being a winner in a video game. Many a fragile gamer-ego can’t admit that they’d quite like a relaxing game that doesn’t constantly challenge them to the max. I do.

Every thing U can do with a Link-List + Programming_it_in_JaVa

Linked List
A linked list is a sequence of data structures, which are connected together via links.
Linked List is a sequence of links which contains items. Each link contains a connection to another link. Linked list is the second most-used data structure after array. 
Following are the important terms to understand the concept of Linked List:
  • Link − Each link of a linked list can store a data called an element.
  • Next − Each link of a linked list contains a link to the next link called Next.
  • LinkedList − A Linked List contains the connection link to the first link called First.
Linked list can be visualized as a chain of nodes, where every node points to the next node:
As per the above illustration, following are the important points to be considered.
  • Linked List contains a link element called first.
  • Each link carries a data field(s) and a link field called next.
  • Each link is linked with its next link using its next link.
  • Last link carries a link as null to mark the end of the list.
Basic Operations:
Following are the basic operations supported by a list.
  • Insertion − Adds an element at the beginning of the list.
  • Deletion − Deletes an element at the beginning of the list.
  • Display − Displays the complete list.
  • Search − Searches an element using the given key.
  • Delete − Deletes an element using the given key.

Insertion Operation:

Adding a new node in linked list is a more than one step activity.First, create a node using the same structure and find the location where it has to be inserted.
Insertion operation
Imagine that we are inserting a node B (NewNode), between A (LeftNode) and C (RightNode). Then point B.next to C −
NewNode.next −> RightNode;
It should look like this −
Insertion operation
Now, the next node at the left should point to the new node.
LeftNode.next −> NewNode;
Insertion operation
This will put the new node in the middle of the two. The new list should look like this −
Insertion operation
Similar steps should be taken if the node is being inserted at the beginning of the list. While inserting it at the end, the second last node of the list should point to the new node and the new node will point to NULL.

Deletion Operation

Deletion is also a more than one step process. First, locate the target node to be removed.
Deletion Operation
The left (previous) node of the target node now should point to the next node of the target node −
LeftNode.next −> TargetNode.next;
This will remove the link that was pointing to the target node. Now, using the following code, we will remove what the target node is pointing at.
TargetNode.next −> NULL;
We need to use the deleted node. We can keep that in memory otherwise we can simply deallocate memory and wipe off the target node completely.
Deletion Operation

Reverse Operation:

This operation is a thorough one. We need to make the last node to be pointed by the head node and reverse the whole linked list.
Reverse Operation:

First, we traverse to the end of the list. It should be pointing to NULL. Now, we shall make it point to its previous node −
Reverse Operation:
We have to make sure that the last node is not the lost node. So we’ll have some temp node, which looks like the head node pointing to the last node. Now, we shall make all left side nodes point to their previous nodes one by one.
Reverse Operation:
Except the node (first node) pointed by the head node, all nodes should point to their predecessor, making them their new successor. The first node will point to NULL.
Reverse Operation:
We’ll make the head node point to the new first node by using the temp node.
Reverse Operation:
The linked list is now reversed.

Java LinkedList class

Java LinkedList class uses doubly linked list to store the elements. It provides a linked-list data structure. It inherits the AbstractList class and implements List and Deque interfaces.

Doubly LinkedList:A Doubly Linked List (DLL) contains an extra pointer, typically called previous pointer, together with next pointer and data which are there in singly linked list.

Doubly LinkedList
ns
The important points about Java LinkedList are:
  • Java LinkedList class can contain duplicate elements.
  • Java LinkedList class maintains insertion order.
  • Java LinkedList class is non synchronized.
  • In Java LinkedList class, manipulation is fast because no shifting needs to be occurred.
  • Java LinkedList class can be used as list, stack or queue.

LinkedList Class Representation:

  1. public class LinkedList extends AbstractSequentialList
  2. implements List  

Constructors of Java LinkedList:

Constructor Description
LinkedList() It is used to construct an empty list.
LinkedList(Collection c) It is used to construct a list containing the elements of the specified collection, in the order they are returned by the collection’s iterator.

Methods of Java LinkedList:

Method Description
void add(int index, Object element) It is used to insert the specified element at the specified position index in a list.
void addFirst(Object o) It is used to insert the given element at the beginning of a list.
void addLast(Object o) It is used to append the given element to the end of a list.
int size() It is used to return the number of elements in a list
boolean add(Object o) It is used to append the specified element to the end of a list.
boolean contains(Object o) It is used to return true if the list contains a specified element.
boolean remove(Object o) It is used to remove the first occurence of the specified element in a list.
Object getFirst() It is used to return the first element in a list.
Object getLast() It is used to return the last element in a list.
int indexOf(Object o) It is used to return the index in a list of the first occurrence of the specified element, or -1 if the list does not contain any element.
int lastIndexOf(Object o) It is used to return the index in a list of the last occurrence of the specified element, or -1 if the list does not contain any element.

Let’s now see an example of LinkedList in java:
import java.util.*;
public class SuvenConsultants{
public static void main(String args[]) {

/* Linked List Declaration */
LinkedList<String> linkedlist = new LinkedList<String>();

/*add(String Element) is used for adding
* the elements to the linked list*/

linkedlist
.add("Android");
linkedlist
.add("Web Technology");


/*Display Linked List Content*/
System.out.println("Linked List Content: " +linkedlist);

/*Add First and Last Element*/
linkedlist
.addFirst("Database");
linkedlist
.addLast("Java");
System.out.println("LinkedList Content after addition: " +linkedlist);

/*This is how to get and set Values*/
Object firstvar = linkedlist.get(0);
System.out.println("First element: " +firstvar);
linkedlist
.set(0, "Data Analytics");
Object firstvar2 = linkedlist.get(0);
System.out.println("First element after update by set method: " +firstvar2);

/*Remove first and last element*/
linkedlist
.removeFirst();
linkedlist
.removeLast();
System.out.println("LinkedList after deletion of first and last element: " +linkedlist);

/* Add to a Position and remove from a position*/
linkedlist
.add(0, "Python");
linkedlist
.remove(2);
System.out.println("Final Content: " +linkedlist);
}
}
Output:
Linked List Content: [Android, Web Technologies]
LinkedList Content after addition: [Database,Android, Web Technologies,Java]
First element: Database
First element after update by set method: Data Analytics
LinkedList after deletion of first and last element: [Android, Web Technologies]
Final Content: [Python, Android]

Advantages of Linked Lists

  • They are a dynamic in nature which allocates the memory when required.
  • Linked List can grow and shrink during run time.
  • Insertion and deletion operations can be easily implemented.
  • Stacks and queues can be easily executed

Disadvantages of Linked List

  • The memory is wasted as pointers require extra memory for storage.
  • No element can be accessed randomly; it has to access each node sequentially.
  • Reverse Traversing is difficult in linked list.

Want to learn more about Java?

Best gifts for gamers

A lot of people who own smartphones and tablets use them for more than surfing the internet, texting, and socializing. They also use them a lot to play games. In a recent survey from Statista, 56 percent, or over half of the entire population of the US, are currently playing mobile games. That amount is expected to expand to 63.7 percent by 2020. But what sort of gifts are the right kind for hardcore gamers?

In this feature, we offer our picks for the best smartphones and tablets that are currently on the market for gaming, along with suggestions for a few accessories that could be great gifts for gamers. Finally, we don’t want to ignore the game consoles that you hook up to your big screen TV; we will offer our recommendation on which of the three current generation game consoles you should buy, and the answer may actually surprise you.

A jack of all trades — ZTE Axon M

Today’s smartphones make great portable gaming devices, while tablets are great for those times when we need a bit more screen real estate from our mobile gaming experience. But what about a wild card of a device that can serve as both your phone and your tablet? The ZTE Axon M is a unique device that is perfect for those that want to take their  gaming to the next level. 

The ZTE Axon M uses two 5.2-inch IPS Full HD panels that are connected to a hinge that, when it is folded out, it essentially turns the device into a 6.75-inch tablet. This is great for running two apps side by side, extending apps and games across both displays, and much more. In addition to the potential for gaming and media, the Axon M also makes for one heck of a multi-tasking device.

As you can imagine, this phone also stands out in a crowd, perfect for those who like to rock phones that are different from the endless sea of Samsung and iPhone devices.Without a doubt, this is one of the most unique phones you can buy right now. You can get it via AT&T for $724.99 without a contract, or for $24.17 a month for 24 months. 

Get it at AT&T

Best gaming phone — Razer Phone

If you want to get a smartphone that’s dedicated to offering the best mobile gaming experience, it’s really impossible to beat the Razer Phone at the moment. This is the first smartphone from Razer, who has been highly successful in releasing PC accessories for hardcore gamers, and more recently has launched critically acclaimed Windows-based gaming laptops. For their first, but likely not last, entry in the smartphone industry, Razer put in a bunch of high-end hardware, including a couple of features that are not in any other smartphone.

Editor’s Pick

The biggest feature for gamers is the Razer Phone’s big IGZO 5.7-inch 2,560 x 1,440p display, which can run at up to 120 Hz. The higher refresh rate, compared to the normal 60 Hz on other smartphones, should allow games, especially high-end titles with advanced graphics, to play and look smoother on the Razer Phone. The display also uses what Razer calls Ultra Motion technology, which is similar to NVIDIA’s G-Sync tech that is supported by many PC desktop monitors. Ultra Motion allows the Razer Phone’s display refresh rate to sync up to the output of its GPU. This is supposed to get rid of any screen tearing and, again, make games played on the phone look and run better compared to other handsets.

In addition to the high-end visuals, the Razer Phone has the Qualcomm Snapdragon 835 processor inside, which, at the moment, is the fastest chip you can get on a phone. It also has 8 GB of LPDRR4 RAM, which again should help graphically intensive games perform better. There’s 64 GB of onboard storage, and you can add more with its microSD card slot. In terms of audio, Razer claims it has the loudest phone on the market, with two front-facing speakers with Dolby Atmos technology. There’s no 3.5 mm headphone jack in the Razer Phone, but it does include a dongle for its USB-C port that includes support for 24-bit DAC audio that is THX-certified. Finally, it has a large 4,000 mAh battery that Razer says should allow for up to 8 hours of gaming on one charge, which should be plenty if you are on a long trip.

Simply put, mobile gamers won’t be able to get a phone quite as good as the Razer Phone for a while, and it’s actually a great first effort from a company that has never launched a smartphone before. The price is also right at $699.99 unlocked, which is very reasonable when you consider the high-end hardware inside. If you can ignore its non-gaming issues, the Razer Phone is one of the best gifts for gamers you can buy.

Get it at Razerzone

Alternate gaming phone — Samsung Galaxy Note 8 

 
Bigger is definitely better when it comes to mobile gaming. The Samsung Galaxy Note 8, with its 6.3-inch Super AMOLED 2,960 x 1,440 display in an 18.5:9 aspect ratio, offers up the biggest and best screen you can get in the US on an Android smartphone. It helps that the phone also comes with a speedy Qualcomm Snapdragon 835 processor and 6 GB of RAM. You even get an old-fashioned headphone jack with the Note 8. While it doesn’t have a 120 Hz screen refresh rate or the advanced sound features that the Razer phone does, gamers should get a lot out of its huge screen combined with a fast processor. It’s not cheap, but at least you can pay for the Galaxy Note 8 over time if you get it from a wireless carrier.
 
Get it at Amazon

Best gaming tablet — Samsung Galaxy Tab S3

 
Samsung’s recent high-end Android tablet is the best among gifts for gamers. It has a 9.7-inch Super AMOLED display with a resolution of 2,048 x 1,536 pixels, with support for high dynamic range (HDR) features that should allow games to look and play well. While the Tab S3 doesn’t have as much in the RAM and processor department as some smartphones, it uses the older Qualcomm Snapdragon 820 chip and 4 GB of RAM. However, the well-designed display, combined with four speakers, makes the Tab S3 the best, at least for now, for Android gaming, although perhaps not as good of an overall choice compared to many high-end Android phones.
 
Editor’s Pick
 
The Samsung Galaxy Tab S3 was launched earlier this year at $599, but you can snap it up now on Amazon and save over $100, at $498.
Get it at Amazon

Alternate — Amazon Fire HD 10 

 
If you are looking for a solid but inexpensive gaming tablet, you really should look no further than the Amazon Fire HD 10. The 10.1 inch 1080p (1,920 x 1,200) display can handle any game, and it has a decent 1.8 GHz quad-core processor and 2 GB RAM. While it’s not as powerful as the Galaxy Tab S3, those folks looking to save some money will still get a good gaming experience with Amazon’s highest-end tablet. You can get it for as low as $149.99 (with 32 GB and with “special offers” on its lock screen).
 
Get it at Amazon

Gamer accessory gifts 

Chromecast Ultra
 
 
Want to play thousands of Android games on your big 4K TV? You can. if you connect the Chromecast Ultra HDMI dongle to one of your spare HDMI ports. Just cast your games onto the screen with this $69 accessory, and play like you would on a game console.
 
Get it at Google

POWER A MOGA Hero Power Game Controller

 

No matter how powerful your gaming smartphone may be, it can still be hard to control games with its touchscreen, especially for games like racing and shooter titles. The POWER A MOGA Hero Power Game Controller allows you to connect your smartphone to a Bluetooth-based console gamepad, and you can even attach any smartphone up to 6-inches to the controller, letting you play for hours without having to worry about holding your phone on its own. It also comes with its own rechargeable 1,800 mAh battery. If you want a portable console experience for your smartphone, this controller will fit the bill nicely.

Get it at Amazon

Samsung Gear VR — 2017 edition

The current 2017 version of the Samsung Gear VR mobile headset (co-developed by Oculus) lets you play VR games, many of which are exclusive to the Gear VR. Owners of the Samsung Galaxy Note 8, along with the Galaxy S8, S8 Plus, Galaxy S7, Galaxy S7 Edge, Galaxy S6, Galaxy S6 Edge, Galaxy S6 Edge Plus, and even the Galaxy Note 5 can all use the headset, which comes with its own controller. If you happen to own one of these phones, it’s perhaps the best way to experience high-end VR gaming.

Get it at Amazon

 Anker PowerCore Speed 10,000 mAh Battery Charger

The simple fact is that even if you have a big batter on your smartphone, like the 4,000 mAh battery on the Razer Phone, it will still run out in less than a day if you play on it constantly. That’s why it’s great to have an external battery charger like the Anker PowerCore Speed 10,000 mAh model. It can charge up your Razer Phone twice on its own, giving you more time to play on your high end handset. It’s also available for just $29 at Amazon.

Get it at Amazon

Best Game Console – Nintendo Switch

The Nintendo Switch is perhaps the best game console you can buy for a gamer on the go. Simply put, the Switch can turn quickly from a high-end game console that you hook up to your TV over to a portable handheld console, where you can play for up to six hours on its own battery. You can play it with two of the console’s Joy-Con controllers, one on each side, or you and a friend can play games on the portable screen, each with a Joy-Con in your hands. You can even put a pair of these new controllers in a Joy-Con grip accessory, if you want a more old-fashioned console experience.

Plus there’s the fact that the Nintendo Switch is the exclusive way to play some of the most acclaimed games of 2017, including Super Mario Odyssey, The Legend of Zelda: Breath of the Wild, Mario Kart 8 Deluxe, and many more. Finally, it’s likely that the hardcore gamer that you want to spend your money on already has a PlayStation 4/4 Pro, or an Xbox One S/X. He or she might think that the Nintendo Switch is for kids or families, but the purchase of Nintendo’s latest — and possibly best — game console in years might convert them into fans.

Get it at Amazon
 
Those are just some of the best gifts you can get for gamers. We want to hear from you about which gifts for gamers you would pick out for fans. Let us know your thoughts and suggestions in the comments!
Disclosure: E-Commerce Content is independent of editorial content and we may receive compensation in connection with your purchase of products via links on this page. This post may contain affiliate links. See our disclosure policy for more details.